To run: Beforehand:

module load pandoc

In R:

setwd("~/shared-gandalm/brain_CTP/Scripts/methylation/analysis/unsupervised")
rmarkdown::render("methylation_unsupervised_eda.Rmd", "html_document")

1 Jaffe et al. 2018

1.1 Set-up

1.1.1 Directories and libraries

# QC-ed data (meffil pipeline)
eigenval_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_aut_mask.eigenval"
eigenvec_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_aut_mask.eigenvec"
eigenval_sd02_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_sd02_aut_mask.eigenval"
eigenvec_sd02_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_sd02_aut_mask.eigenvec"
eigenval_sd02_age18_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask.eigenval"
eigenvec_sd02_age18_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask.eigenvec"
eigenval_sd02_fetal_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_fetal_sd02_aut_mask.eigenval"
eigenvec_sd02_fetal_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_fetal_sd02_aut_mask.eigenvec"
pheno_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed/pheno_Jaffe2018.txt"

# Also check PCA calculated using Jaffe et al. 2018 processed data
eigenval_jaffe_sd02_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep_sd02_aut_mask.eigenval"
eigenvec_jaffe_sd02_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep_sd02_aut_mask.eigenvec"

# Jaffe CTP
ctp_jaffe_dir <- "~/shared-gandalm/GenomicDatasets/Jaffe_methylation_DLFPC/pheno/GSE74193_series_matrix_pheno_df.txt" 

# ReFACTor components
refactor_k8_age18_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_cov.refactor.components.txt"
refactor_k8_age18_probe_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_cov.refactor.rankedlist.txt"
refactor_k8_age18ctrl_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_cov_controls.refactor.components.txt"
refactor_k8_age18ctrl_probe_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_cov_controls.refactor.rankedlist.txt"
refactor_k8_fetal_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_fetal_sd02_aut_mask_cov.refactor.components.txt"
refactor_k8_fetal_probe_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_fetal_sd02_aut_mask_cov.refactor.rankedlist.txt"
ilmn450k.gr_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/reference/HM450.hg19.manifest.rds"
refactor_k8_age18_n500.ma_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_cov.refactor.rankedlist_500_t.ma"
refactor_k8_age18ctrl_n500.ma_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_cov_controls.refactor.rankedlist_500_t.ma"
refactor_k8_fetal_n500.ma_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_fetal_sd02_aut_mask_cov.refactor.rankedlist_500_t.ma"

# Houseman results
hm_na2_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_Luo2020_na2.houseman_estimates.txt"
hm_na5_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/analysis/Jaffe2018_age18_sd02_aut_mask_Luo2020_na5.houseman_estimates.txt"

# proc_keep_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep.rds"
#proc_keep_eigenval_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep.eigenval"
#proc_keep_eigenvec_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep.eigenvec"
# proc_keep_filter_eigenval_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep_mask_sd02.eigenval"
# proc_keep_filter_eigenvec_dir <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep_mask_sd02.eigenvec"
# jaffe.keep_dir <- "/u/project/gandalm/shared/GenomicDatasets/Jaffe_methylation_DLFPC/pheno/GSE74193_series_matrix_pheno_keep_df.txt"
#mask_dir <- "/u/project/gandalm/shared/GenomicDatasets/Jaffe_methylation_DLFPC/EPIC.hg38.manifest_MASK_general.probe"

# pca_out <- "~/shared-gandalm/brain_CTP/Data/methylation/Jaffe2018/processed_Jaffe/GSE74193_GEO_procData_beta_keep_PC"

library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✔ ggplot2 3.3.3     ✔ purrr   0.3.4
## ✔ tibble  3.0.4     ✔ dplyr   1.0.2
## ✔ tidyr   1.1.2     ✔ stringr 1.4.0
## ✔ readr   1.4.0     ✔ forcats 0.5.0
## ── Conflicts ───────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(rmarkdown)    # You need this library to run this template.
library(epuRate)      # Install with remotes::install_github("holtzy/epuRate", force=TRUE) - use this instead of devtools::install_github()
library(data.table)
## data.table 1.13.6 using 4 threads (see ?getDTthreads).  Latest news: r-datatable.com
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:purrr':
## 
##     transpose
library(DT)
library(tidyverse)
library(plyr)
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
## 
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following object is masked from 'package:purrr':
## 
##     compact
library(reshape2)
## 
## Attaching package: 'reshape2'
## The following objects are masked from 'package:data.table':
## 
##     dcast, melt
## The following object is masked from 'package:tidyr':
## 
##     smiths
library(uwot) # for umap
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
library(mixOmics)
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
## Loading required package: lattice
## 
## Loaded mixOmics 6.14.0
## Thank you for using mixOmics!
## Tutorials: http://mixomics.org
## Bookdown vignette: https://mixomicsteam.github.io/Bookdown
## Questions, issues: Follow the prompts at http://mixomics.org/contact-us
## Cite us:  citation('mixOmics')
## 
## Attaching package: 'mixOmics'
## The following object is masked from 'package:purrr':
## 
##     map
library(factoextra)
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(ggplot2)
library(RColorBrewer)
library(viridis)
## Loading required package: viridisLite
library(ggpubr)
## 
## Attaching package: 'ggpubr'
## The following object is masked from 'package:plyr':
## 
##     mutate
library(GGally)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
library(lattice)

# BiocManager::install("M3C")
# library(M3C)

1.1.2 Read-in data and order

1.1.2.1 QC-ed data

eigenval <- fread(eigenval_dir)
eigenvec <- fread(eigenvec_dir)
eigenval_sd02 <- fread(eigenval_sd02_dir)
eigenvec_sd02 <- fread(eigenvec_sd02_dir)
eigenval_sd02_age18 <- fread(eigenval_sd02_age18_dir)
eigenvec_sd02_age18 <- fread(eigenvec_sd02_age18_dir)
eigenval_sd02_fetal <- fread(eigenval_sd02_fetal_dir)
eigenvec_sd02_fetal <- fread(eigenvec_sd02_fetal_dir)

colnames(eigenval) <- "eigenvalue"
colnames(eigenval_sd02) <- "eigenvalue"
colnames(eigenval_sd02_age18) <- "eigenvalue"
colnames(eigenval_sd02_fetal) <- "eigenvalue"

colnames(eigenvec) <- c("FID", "IID", paste(rep("PC", 10), 1:10, sep = ""))
colnames(eigenvec_sd02) <- c("FID", "IID", paste(rep("PC", 10), 1:10, sep = ""))
colnames(eigenvec_sd02_age18) <- c("FID", "IID", paste(rep("PC", 10), 1:20, sep = ""))
colnames(eigenvec_sd02_fetal) <- c("FID", "IID", paste(rep("PC", 10), 1:20, sep = ""))

pheno <- fread(pheno_dir)

ctp_jaffe <- fread(ctp_jaffe_dir)
ctp_jaffe <- ctp_jaffe[,c("title", "comp_da_neuron", "comp_es", "comp_neun_neg", "comp_neun_pos", "comp_npc")]
colnames(ctp_jaffe)[1] <- "IID"

1.1.2.2 Jaffe et al. processed

eigenval_jaffe_sd02 <- read.delim(eigenval_jaffe_sd02_dir, header = F, as.is = T)
colnames(eigenval_jaffe_sd02) <- "eigenvalue"
eigenvec_jaffe_sd02 <- read.table(eigenvec_jaffe_sd02_dir, header = F, as.is = T)
colnames(eigenvec_jaffe_sd02) <- c("FID", "IID", paste(rep("PC", 10), 1:10, sep = ""))

#proc_keep_filter.eigenval <- read.delim(proc_keep_filter_eigenval_dir, header = F, as.is = T)
#colnames(proc_keep_filter.eigenval) <- "eigenvalue"
#proc_keep_filter.eigenvec <- read.table(proc_keep_filter_eigenvec_dir, header = F, as.is = T)
#colnames(proc_keep_filter.eigenvec) <- c("FID", "IID", paste(rep("PC", 10), 1:10, sep = ""))

#jaffe.keep <- read.delim(jaffe.keep_dir, header = T, as.is = T)
#colnames(jaffe.keep)[1] <- "IID"

1.2 Check PCA concordance across filters and pipelines

1.2.1 Scree plots for % variance explained

  • overall, looks like sd02 filter improves PCA

meffil pipeline, no sd02 filter

eigenval$variance_pc <- eigenval$eigenvalue/sum(eigenval$eigenvalue)
eigenval$variance_total <- cumsum(eigenval$variance_pc)
eigenval$PC <- 1:nrow(eigenval)
eigenval$filter <- "meffil"

meffil pipeline, with sd02 filter

eigenval_sd02$variance_pc <- eigenval_sd02$eigenvalue/sum(eigenval_sd02$eigenvalue)
eigenval_sd02$variance_total <- cumsum(eigenval_sd02$variance_pc)
eigenval_sd02$PC <- 1:nrow(eigenval_sd02)
eigenval_sd02$filter <- "meffil_sd02"

meffil pipeline, with sd02 filter, age>=18

eigenval_sd02_age18$variance_pc <- eigenval_sd02_age18$eigenvalue/sum(eigenval_sd02_age18$eigenvalue)
eigenval_sd02_age18$variance_total <- cumsum(eigenval_sd02_age18$variance_pc)
eigenval_sd02_age18$PC <- 1:nrow(eigenval_sd02_age18)
eigenval_sd02_age18$filter <- "meffil_sd02_age18"

meffil pipeline, with sd02 filter, fetal

eigenval_sd02_fetal$variance_pc <- eigenval_sd02_fetal$eigenvalue/sum(eigenval_sd02_fetal$eigenvalue)
eigenval_sd02_fetal$variance_total <- cumsum(eigenval_sd02_fetal$variance_pc)
eigenval_sd02_fetal$PC <- 1:nrow(eigenval_sd02_fetal)
eigenval_sd02_fetal$filter <- "meffil_sd02_fetal"

Jaffe pipeline, with sd02 filter

eigenval_jaffe_sd02$variance_pc <- eigenval_jaffe_sd02$eigenvalue/sum(eigenval_jaffe_sd02$eigenvalue)
eigenval_jaffe_sd02$variance_total <- cumsum(eigenval_jaffe_sd02$variance_pc)
eigenval_jaffe_sd02$PC <- 1:nrow(eigenval_jaffe_sd02)
eigenval_jaffe_sd02$filter <- "Jaffe_sd02"

Graph of all

eigenval_agg <- rbind(eigenval, eigenval_sd02, eigenval_sd02_fetal, eigenval_sd02_fetal, eigenval_jaffe_sd02) %>% filter(PC %in% 1:25)

scree_agg <- ggplot(data=eigenval_agg, aes(x=PC, y=variance_pc)) +
  geom_bar(stat="identity") + facet_wrap(~ filter, nrow = 3)
scree_agg

1.2.2 Correlations across first 10 PCs

  • Plots compares results from 10 PCs from the meffilsd02 set, compared to:
    • 10 PCs from Jaffe_sd02 filter
    • 10 PCs from meffil without sd02 filter
  • Overall
    • PC1-4, 10: meffil_sd02 and Jaffe_sd02 look fairly cocordant
    • PC1-2,4-5: meffil_sd02 and meffil look fairly concordant
    • otherwise, looks like not so concordant
    • note that when only looking at age > 10, there’s not much concordant, suggests that the PCs are picking up a LOT of age
eigenvec_sd02.long <- data.table::melt(eigenvec_sd02, id.vars = c("FID", "IID"), variable.name = "PC", value.name = "value_meffil_sd02")
eigenvec_sd02.long$filter_meffil_sd02 <- "meffil_sd02"

eigenvec_sd02_age18.long <- data.table::melt(eigenvec_sd02_age18, id.vars = c("FID", "IID"), variable.name = "PC")
eigenvec_sd02_age18.long$filter <- "meffil_sd02_age18"

eigenvec_sd02_fetal.long <- data.table::melt(eigenvec_sd02_fetal, id.vars = c("FID", "IID"), variable.name = "PC")
eigenvec_sd02_fetal.long$filter <- "meffil_sd02_fetal"

eigenvec_jaffe_sd02.long <- data.table::melt(eigenvec_jaffe_sd02, id.vars = c("FID", "IID"), variable.name = "PC")
## Warning in data.table::melt(eigenvec_jaffe_sd02, id.vars = c("FID", "IID"), :
## The melt generic in data.table has been passed a data.frame and will attempt
## to redirect to the relevant reshape2 method; please note that reshape2 is
## deprecated, and this redirection is now deprecated as well. To continue using
## melt methods from reshape2 while both libraries are attached, e.g. melt.list,
## you can prepend the namespace like reshape2::melt(eigenvec_jaffe_sd02). In the
## next version, this warning will become an error.
eigenvec_jaffe_sd02.long$filter <- "Jaffe_sd02"

# Join together
tmp1 <- join(eigenvec_sd02_age18.long, eigenvec_sd02.long, by = c("FID", "IID", "PC"), type = "inner")
tmp2 <- join(eigenvec_sd02_fetal.long, eigenvec_sd02.long, by = c("FID", "IID", "PC"), type = "inner")
tmp3 <- join(eigenvec_jaffe_sd02.long, eigenvec_sd02.long, by = c("FID", "IID", "PC"), type = "inner")
tmp4 <- rbind(tmp1, tmp2, tmp3)

ggplot(tmp4, aes(x=value, y=value_meffil_sd02)) + 
  geom_point() +
  facet_grid(rows = vars(PC), cols = vars(filter))

1.3 Plot PCs

1.3.1 Add metadata first

eigenvec_sd02_pheno <- join(eigenvec_sd02, pheno, by = c("FID", "IID"), type = "inner")
eigenvec_sd02_age18_pheno <- join(eigenvec_sd02_age18, pheno, by = c("FID", "IID"), type = "inner")
eigenvec_sd02_fetal_pheno <- join(eigenvec_sd02_fetal, pheno, by = c("FID", "IID"), type = "inner")
eigenvec_jaffe_sd02_pheno <- join(eigenvec_jaffe_sd02, pheno, by = c("FID", "IID"), type = "inner")

1.3.2 Check associations with each PC

  • N.B. didn’t include slide as difficult to plot nicely

meffil with sd02 filter

eigenvec_sd02_pheno_PC12.group <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC2, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC12.sex <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC2, colour = sex)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC12.age <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC2, colour = age)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC12.race <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC2, colour = race)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC12.plate <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC2, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_sd02_pheno_PC13.group <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC13.sex <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC3, colour = sex)) +   geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC13.age <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC13.race <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC13.plate <- ggplot(eigenvec_sd02_pheno, aes(x=PC1, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_sd02_pheno_PC23.group <- ggplot(eigenvec_sd02_pheno, aes(x=PC2, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC23.sex <- ggplot(eigenvec_sd02_pheno, aes(x=PC2, y=PC3, colour = sex)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC23.age <- ggplot(eigenvec_sd02_pheno, aes(x=PC2, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC23.race <- ggplot(eigenvec_sd02_pheno, aes(x=PC2, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_pheno_PC23.plate <- ggplot(eigenvec_sd02_pheno, aes(x=PC2, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

meffil with sd02 filter, age >= 18

eigenvec_sd02_age18_pheno_PC12.group <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC2, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC12.sex <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC2, colour = sex)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC12.age <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC2, colour = age)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC12.race <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC2, colour = race)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC12.plate <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC2, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_sd02_age18_pheno_PC13.group <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC13.sex <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC3, colour = sex)) +   geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC13.age <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC13.race <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC13.plate <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC1, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_sd02_age18_pheno_PC23.group <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC2, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC23.sex <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC2, y=PC3, colour = sex)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC23.age <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC2, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC23.race <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC2, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_PC23.plate <- ggplot(eigenvec_sd02_age18_pheno, aes(x=PC2, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

meffil with sd02 filter, fetal

eigenvec_sd02_fetal_pheno_PC12.group <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC2, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC12.sex <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC2, colour = sex)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC12.age <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC2, colour = age)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC12.race <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC2, colour = race)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC12.plate <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC2, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_sd02_fetal_pheno_PC13.group <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC13.sex <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC3, colour = sex)) +   geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC13.age <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC13.race <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC13.plate <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC1, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_sd02_fetal_pheno_PC23.group <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC2, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC23.sex <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC2, y=PC3, colour = sex)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC23.age <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC2, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC23.race <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC2, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_PC23.plate <- ggplot(eigenvec_sd02_fetal_pheno, aes(x=PC2, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

Jaffe with sd02 filter

eigenvec_jaffe_sd02_pheno_PC12.group <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC2, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC12.sex <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC2, colour = sex)) + geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC12.age <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC2, colour = age)) + geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC12.race <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC2, colour = race)) + geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC12.plate <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC2, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_jaffe_sd02_pheno_PC13.group <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC13.sex <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC3, colour = sex)) +   geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC13.age <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC13.race <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC13.plate <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC1, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

eigenvec_jaffe_sd02_pheno_PC23.group <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC2, y=PC3, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC23.sex <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC2, y=PC3, colour = sex)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC23.age <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC2, y=PC3, colour = age)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC23.race <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC2, y=PC3, colour = race)) +  geom_point() + theme(legend.position = "bottom")
eigenvec_jaffe_sd02_pheno_PC23.plate <- ggplot(eigenvec_jaffe_sd02_pheno, aes(x=PC2, y=PC3, colour = plate)) + geom_point() + theme(legend.position = "bottom")

1.3.3 Plots

1.3.3.1 PC1/PC2

ggarrange(eigenvec_sd02_pheno_PC12.group, eigenvec_sd02_age18_pheno_PC12.group, eigenvec_sd02_fetal_pheno_PC12.group, eigenvec_jaffe_sd02_pheno_PC12.group, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC12.sex, eigenvec_sd02_age18_pheno_PC12.sex, eigenvec_sd02_fetal_pheno_PC12.sex, eigenvec_jaffe_sd02_pheno_PC12.sex, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC12.age, eigenvec_sd02_age18_pheno_PC12.age, eigenvec_sd02_fetal_pheno_PC12.age, eigenvec_jaffe_sd02_pheno_PC12.age,
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC12.race, eigenvec_sd02_age18_pheno_PC12.race, eigenvec_sd02_fetal_pheno_PC12.race, eigenvec_jaffe_sd02_pheno_PC12.race,
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC12.plate, eigenvec_sd02_age18_pheno_PC12.plate, eigenvec_sd02_fetal_pheno_PC12.plate, eigenvec_jaffe_sd02_pheno_PC12.plate,
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

1.3.3.2 PC1/PC3

ggarrange(eigenvec_sd02_pheno_PC13.group, eigenvec_sd02_age18_pheno_PC13.group, eigenvec_sd02_fetal_pheno_PC13.group, eigenvec_jaffe_sd02_pheno_PC13.group,
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC13.sex, eigenvec_sd02_age18_pheno_PC13.sex, eigenvec_sd02_fetal_pheno_PC13.sex, eigenvec_jaffe_sd02_pheno_PC13.sex,
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC13.age, eigenvec_sd02_age18_pheno_PC13.age, eigenvec_sd02_fetal_pheno_PC13.age, eigenvec_jaffe_sd02_pheno_PC13.age, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC13.race, eigenvec_sd02_age18_pheno_PC13.race, eigenvec_sd02_fetal_pheno_PC13.race, eigenvec_jaffe_sd02_pheno_PC13.race, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC13.plate, eigenvec_sd02_age18_pheno_PC13.plate, eigenvec_sd02_fetal_pheno_PC13.plate, eigenvec_jaffe_sd02_pheno_PC13.plate, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

1.3.3.3 PC2/PC3

ggarrange(eigenvec_sd02_pheno_PC23.group, eigenvec_sd02_age18_pheno_PC23.group, eigenvec_sd02_fetal_pheno_PC23.group, eigenvec_jaffe_sd02_pheno_PC23.group,
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC23.sex, eigenvec_sd02_age18_pheno_PC23.sex, eigenvec_sd02_fetal_pheno_PC23.sex, eigenvec_jaffe_sd02_pheno_PC23.sex,
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC23.age, eigenvec_sd02_age18_pheno_PC23.age, eigenvec_sd02_fetal_pheno_PC23.age, eigenvec_jaffe_sd02_pheno_PC23.age, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC23.race, eigenvec_sd02_age18_pheno_PC23.race, eigenvec_sd02_fetal_pheno_PC23.race, eigenvec_jaffe_sd02_pheno_PC23.race, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

ggarrange(eigenvec_sd02_pheno_PC23.plate, eigenvec_sd02_age18_pheno_PC23.plate, eigenvec_sd02_fetal_pheno_PC23.plate, eigenvec_jaffe_sd02_pheno_PC23.plate, 
          labels = c("mef02", "mef02_18", "mef02_fe", "jaffe"),
          ncol = 4, nrow = 1, common.legend = TRUE, legend = "bottom")

1.4 Plot UMAP using PCs

  • Only take forward eigenvec_sd02_fetal - seems to reduce spread well
  • Input: 10 PCs (=63% of variance)
  • uwot package (selected purely on the superior package naming https://github.com/jlmelville/uwot)

1.4.1 Age > 18

1.4.1.1 UMAP plots

eigenvec_sd02_age18.umap <- data.frame(uwot::umap(eigenvec_sd02_age18[,3:ncol(eigenvec_sd02_age18)]))
colnames(eigenvec_sd02_age18.umap) <- c("UMAP1", "UMAP2")
eigenvec_sd02_age18.umap$IID <- eigenvec_sd02_age18$IID

eigenvec_sd02_age18_pheno_umap <- join(eigenvec_sd02_age18_pheno, eigenvec_sd02_age18.umap, by = "IID", type = "inner")

eigenvec_sd02_age18_pheno_umap.group <- ggplot(eigenvec_sd02_age18_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_umap.sex <- ggplot(eigenvec_sd02_age18_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = sex)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_umap.age <- ggplot(eigenvec_sd02_age18_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = age)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_umap.race <- ggplot(eigenvec_sd02_age18_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = race)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_age18_pheno_umap.plate <- ggplot(eigenvec_sd02_age18_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = plate)) + geom_point() + theme(legend.position = "bottom")

ggarrange(eigenvec_sd02_age18_pheno_umap.group, eigenvec_sd02_age18_pheno_umap.sex, eigenvec_sd02_age18_pheno_umap.age, eigenvec_sd02_age18_pheno_umap.race, eigenvec_sd02_age18_pheno_umap.plate, nrow = 3, ncol = 2)

1.4.1.2 Check batches

  • look closer at the plates –> now look at slides
  • do separately as so many factors for slides –> doesn’t visualise so well

1.4.1.3 Number per batch

  • seems strange that there are so few on some batches?
table(eigenvec_sd02_age18_pheno_umap$slide)
## 
## 5771710013 5771710015 5771710017 5771710022 5771710023 5771710036 5771710037 
##          9          7         12         11          9          8          7 
## 5771710038 5806484004 5806484008 5806484010 5806484023 5806484024 5806484056 
##          8          8          8          4          3         10          8 
## 5806484057 5806636054 5815129004 5815129009 5815129011 5815129015 5815129018 
##          8          1         11         12         11         10         12 
## 5815129027 5815129028 5815188011 5815188020 5815188021 5815188022 5815188023 
##         10         12          8          5          8          7          5 
## 6229009001 6229009004 6229009040 6229009047 6229009049 6229009050 6229009056 
##          5          8          9          4          7         10          5 
## 6229009069 6229009079 6229009080 6229009083 6229009084 6229009100 6229009101 
##          8          7          6          5          3          5          2 
## 6229009106 6229009107 6229009112 6229009147 6229009151 6229009153 6229009162 
##          1          2          6          1          4          1          9 
## 6229009166 7810920047 7810920048 7810920075 7810920088 7810920089 7810920091 
##          2          2          4          5          3          4          5 
## 7810920102 7810920123 7810920128 7810920166 7810920178 7927554017 7927554041 
##          1          5          1          1          1          2          1 
## 7927554078 7927554080 7927554092 7927554093 7927554109 7927554120 7927554124 
##          2          2          1          5          5          3          8

1.4.1.4 Visualise batches (UMAP)

  • looks quite batchy …
  • Slides inferred from .idat file names
ggplot(eigenvec_sd02_age18_pheno_umap, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = as.factor(slide))) + scale_color_viridis(discrete = TRUE, option = "D") + theme(legend.position = "bottom")

1.4.1.5 Overlay cell type proportions inferred by Jaffe et al.

eigenvec_sd02_age18_pheno_umap_ctp_jaffe <- join(eigenvec_sd02_age18_pheno_umap, ctp_jaffe, by = "IID", type = "inner")

eigenvec_sd02_age18_pheno_umap_ctp_jaffe.tmp <- eigenvec_sd02_age18_pheno_umap_ctp_jaffe[,c("IID", "UMAP1", "UMAP2", "comp_da_neuron", "comp_es", "comp_neun_neg", "comp_neun_pos", "comp_npc")]

eigenvec_sd02_age18_pheno_umap_ctp_jaffe.long <- melt(eigenvec_sd02_age18_pheno_umap_ctp_jaffe.tmp, id.vars = c("IID", "UMAP1", "UMAP2"), measure.vars = c("comp_da_neuron", "comp_es", "comp_neun_neg", "comp_neun_pos", "comp_npc"), variable.name = "celltype", value.name = "CTP")

ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe.long, aes(x = UMAP1, y = UMAP2, alpha = 0.8)) + geom_point(aes(colour = CTP)) + facet_wrap(~ celltype) + scale_color_viridis(discrete = FALSE, option = "D")

comp_da_neuron.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_da_neuron)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
comp_es.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_es)) + scale_color_viridis(discrete = FALSE, option = "D") + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
comp_neun_neg.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_neun_neg)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
comp_neun_pos.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_neun_pos)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
comp_npc.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_npc)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")

ggarrange(comp_da_neuron.umap, comp_es.umap, comp_neun_neg.umap, comp_neun_pos.umap, comp_npc.umap, nrow = 3, ncol = 2)

1.4.2 Fetal

1.4.2.1 UMAP plots

eigenvec_sd02_fetal.umap <- data.frame(uwot::umap(eigenvec_sd02_fetal[,3:ncol(eigenvec_sd02_fetal)]))
colnames(eigenvec_sd02_fetal.umap) <- c("UMAP1", "UMAP2")
eigenvec_sd02_fetal.umap$IID <- eigenvec_sd02_fetal$IID

eigenvec_sd02_fetal_pheno_umap <- join(eigenvec_sd02_fetal_pheno, eigenvec_sd02_fetal.umap, by = "IID", type = "inner")

eigenvec_sd02_fetal_pheno_umap.group <- ggplot(eigenvec_sd02_fetal_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = group)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_umap.sex <- ggplot(eigenvec_sd02_fetal_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = sex)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_umap.age <- ggplot(eigenvec_sd02_fetal_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = age)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_umap.race <- ggplot(eigenvec_sd02_fetal_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = race)) + geom_point() + theme(legend.position = "bottom")
eigenvec_sd02_fetal_pheno_umap.plate <- ggplot(eigenvec_sd02_fetal_pheno_umap, aes(x = UMAP1, y = UMAP2, colour = plate)) + geom_point() + theme(legend.position = "bottom")

ggarrange(eigenvec_sd02_fetal_pheno_umap.group, eigenvec_sd02_fetal_pheno_umap.sex, eigenvec_sd02_fetal_pheno_umap.age, eigenvec_sd02_fetal_pheno_umap.race, eigenvec_sd02_fetal_pheno_umap.plate, nrow = 3, ncol = 2)

1.4.2.2 Check batches

  • look closer at the plates –> now look at slides
  • do separately as so many factors for slides –> doesn’t visualise so well

1.4.2.3 Number per batch

  • seems strange that there are so few on some batches?
table(eigenvec_sd02_fetal_pheno_umap$slide)
## 
## 5806484010 5815188023 5815188024 5815188028 6229009083 6229009100 6229009145 
##          4          6          7          8          1          1          4 
## 6229009146 6229009147 7927554092 
##          2          1          1

1.4.2.4 Visualise batches (UMAP)

  • looks quite batchy …
  • Slides inferred from .idat file names
ggplot(eigenvec_sd02_fetal_pheno_umap, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = as.factor(slide))) + scale_color_viridis(discrete = TRUE, option = "D") + theme(legend.position = "bottom")

1.4.2.5 Overlay cell type proportions inferred by Jaffe et al.

eigenvec_sd02_fetal_pheno_umap_ctp_jaffe <- join(eigenvec_sd02_fetal_pheno_umap, ctp_jaffe, by = "IID", type = "inner")

eigenvec_sd02_fetal_pheno_umap_ctp_jaffe.tmp <- eigenvec_sd02_fetal_pheno_umap_ctp_jaffe[,c("IID", "UMAP1", "UMAP2", "comp_da_neuron", "comp_es", "comp_neun_neg", "comp_neun_pos", "comp_npc")]

eigenvec_sd02_fetal_pheno_umap_ctp_jaffe.long <- melt(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe.tmp, id.vars = c("IID", "UMAP1", "UMAP2"), measure.vars = c("comp_da_neuron", "comp_es", "comp_neun_neg", "comp_neun_pos", "comp_npc"), variable.name = "celltype", value.name = "CTP")

ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe.long, aes(x = UMAP1, y = UMAP2, alpha = 0.8)) + geom_point(aes(colour = CTP)) + facet_wrap(~ celltype) + scale_color_viridis(discrete = FALSE, option = "D")

comp_da_neuron.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_da_neuron)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
comp_es.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_es)) + scale_color_viridis(discrete = FALSE, option = "D") + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
comp_neun_neg.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_neun_neg)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
comp_neun_pos.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_neun_pos)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
comp_npc.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = comp_npc)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")

ggarrange(comp_da_neuron.umap, comp_es.umap, comp_neun_neg.umap, comp_neun_pos.umap, comp_npc.umap, nrow = 3, ncol = 2)

1.4.2.6 Check linear models of PCs ~ batches

PC1

summary(lm(PC1 ~ as.factor(slide), data = eigenvec_sd02_pheno))
## 
## Call:
## lm(formula = PC1 ~ as.factor(slide), data = eigenvec_sd02_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.155923 -0.008228 -0.000967  0.006466  0.144048 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.012594   0.007897   1.595 0.111491    
## as.factor(slide)5771710015 -0.009333   0.012486  -0.747 0.455171    
## as.factor(slide)5771710017 -0.012132   0.011168  -1.086 0.277945    
## as.factor(slide)5771710022 -0.019661   0.011168  -1.761 0.079023 .  
## as.factor(slide)5771710023 -0.016474   0.011713  -1.407 0.160280    
## as.factor(slide)5771710036 -0.012378   0.011713  -1.057 0.291183    
## as.factor(slide)5771710037 -0.013747   0.012063  -1.140 0.255060    
## as.factor(slide)5771710038 -0.015793   0.012063  -1.309 0.191145    
## as.factor(slide)5806484002  0.013455   0.015794   0.852 0.394714    
## as.factor(slide)5806484004 -0.021896   0.011713  -1.869 0.062244 .  
## as.factor(slide)5806484008 -0.028123   0.012063  -2.331 0.020186 *  
## as.factor(slide)5806484010  0.029452   0.011419   2.579 0.010228 *  
## as.factor(slide)5806484023 -0.004597   0.011713  -0.393 0.694878    
## as.factor(slide)5806484024 -0.022544   0.011713  -1.925 0.054911 .  
## as.factor(slide)5806484056 -0.022620   0.012486  -1.812 0.070727 .  
## as.factor(slide)5806484057 -0.020004   0.012486  -1.602 0.109858    
## as.factor(slide)5806636054 -0.009144   0.011419  -0.801 0.423681    
## as.factor(slide)5806636077 -0.010753   0.013678  -0.786 0.432172    
## as.factor(slide)5815129004 -0.036372   0.011168  -3.257 0.001215 ** 
## as.factor(slide)5815129009 -0.028508   0.011168  -2.553 0.011030 *  
## as.factor(slide)5815129011 -0.024612   0.011419  -2.155 0.031678 *  
## as.factor(slide)5815129015 -0.032597   0.011419  -2.855 0.004514 ** 
## as.factor(slide)5815129018 -0.030837   0.011168  -2.761 0.006002 ** 
## as.factor(slide)5815129027 -0.028340   0.011713  -2.420 0.015948 *  
## as.factor(slide)5815129028 -0.036447   0.011419  -3.192 0.001516 ** 
## as.factor(slide)5815188010 -0.020363   0.028472  -0.715 0.474877    
## as.factor(slide)5815188011 -0.014356   0.011713  -1.226 0.220974    
## as.factor(slide)5815188020 -0.011640   0.011419  -1.019 0.308594    
## as.factor(slide)5815188021 -0.017984   0.012063  -1.491 0.136722    
## as.factor(slide)5815188022 -0.016315   0.013010  -1.254 0.210506    
## as.factor(slide)5815188023  0.063108   0.011168   5.651 2.89e-08 ***
## as.factor(slide)5815188024  0.146092   0.013010  11.229  < 2e-16 ***
## as.factor(slide)5815188028  0.125786   0.012063  10.428  < 2e-16 ***
## as.factor(slide)6229009001 -0.068002   0.013678  -4.972 9.57e-07 ***
## as.factor(slide)6229009004 -0.044793   0.012486  -3.587 0.000372 ***
## as.factor(slide)6229009040 -0.023605   0.012063  -1.957 0.051002 .  
## as.factor(slide)6229009047 -0.035119   0.015794  -2.224 0.026686 *  
## as.factor(slide)6229009049 -0.028639   0.013010  -2.201 0.028241 *  
## as.factor(slide)6229009050 -0.029586   0.011419  -2.591 0.009892 ** 
## as.factor(slide)6229009056 -0.025432   0.014561  -1.747 0.081417 .  
## as.factor(slide)6229009069 -0.015808   0.012486  -1.266 0.206170    
## as.factor(slide)6229009079 -0.025884   0.013010  -1.990 0.047268 *  
## as.factor(slide)6229009080 -0.031012   0.013678  -2.267 0.023858 *  
## as.factor(slide)6229009083 -0.029276   0.014561  -2.011 0.044989 *  
## as.factor(slide)6229009084 -0.020654   0.017658  -1.170 0.242779    
## as.factor(slide)6229009100  0.000887   0.013010   0.068 0.945678    
## as.factor(slide)6229009101 -0.036907   0.020893  -1.766 0.078020 .  
## as.factor(slide)6229009106 -0.061978   0.028472  -2.177 0.030034 *  
## as.factor(slide)6229009107 -0.035741   0.017658  -2.024 0.043573 *  
## as.factor(slide)6229009112 -0.041417   0.013678  -3.028 0.002608 ** 
## as.factor(slide)6229009145  0.136976   0.017658   7.757 6.26e-14 ***
## as.factor(slide)6229009146  0.078669   0.020893   3.765 0.000189 ***
## as.factor(slide)6229009147  0.034128   0.017658   1.933 0.053919 .  
## as.factor(slide)6229009151 -0.050466   0.015794  -3.195 0.001498 ** 
## as.factor(slide)6229009153 -0.058808   0.028472  -2.065 0.039473 *  
## as.factor(slide)6229009162 -0.046537   0.012063  -3.858 0.000132 ***
## as.factor(slide)6229009166 -0.045790   0.020893  -2.192 0.028935 *  
## as.factor(slide)7810920047  0.016833   0.017658   0.953 0.340986    
## as.factor(slide)7810920048 -0.001833   0.013678  -0.134 0.893465    
## as.factor(slide)7810920075 -0.031935   0.014561  -2.193 0.028823 *  
## as.factor(slide)7810920088 -0.029491   0.017658  -1.670 0.095616 .  
## as.factor(slide)7810920089 -0.025036   0.015794  -1.585 0.113651    
## as.factor(slide)7810920091 -0.024775   0.013678  -1.811 0.070777 .  
## as.factor(slide)7810920102 -0.025331   0.028472  -0.890 0.374138    
## as.factor(slide)7810920123 -0.022649   0.014561  -1.555 0.120566    
## as.factor(slide)7810920128  0.015522   0.013010   1.193 0.233487    
## as.factor(slide)7810920166 -0.004008   0.017658  -0.227 0.820534    
## as.factor(slide)7810920178 -0.026193   0.028472  -0.920 0.358109    
## as.factor(slide)7927554017 -0.024730   0.020893  -1.184 0.237198    
## as.factor(slide)7927554041 -0.018713   0.028472  -0.657 0.511370    
## as.factor(slide)7927554078 -0.038674   0.020893  -1.851 0.064840 .  
## as.factor(slide)7927554080 -0.035784   0.020893  -1.713 0.087480 .  
## as.factor(slide)7927554092  0.051739   0.020893   2.476 0.013652 *  
## as.factor(slide)7927554093 -0.037845   0.014561  -2.599 0.009666 ** 
## as.factor(slide)7927554109 -0.028654   0.014561  -1.968 0.049721 *  
## as.factor(slide)7927554120 -0.034964   0.015794  -2.214 0.027363 *  
## as.factor(slide)7927554124 -0.032877   0.012486  -2.633 0.008761 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02736 on 434 degrees of freedom
## Multiple R-squared:  0.6752, Adjusted R-squared:  0.6184 
## F-statistic: 11.87 on 76 and 434 DF,  p-value: < 2.2e-16
summary(lm(PC1 ~ as.factor(slide), data = eigenvec_sd02_age18_pheno))
## 
## Call:
## lm(formula = PC1 ~ as.factor(slide), data = eigenvec_sd02_age18_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.096757 -0.023634 -0.000765  0.019826  0.128832 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.062797   0.013226   4.748 3.06e-06 ***
## as.factor(slide)5771710015 -0.024967   0.019996  -1.249 0.212691    
## as.factor(slide)5771710017 -0.006865   0.017497  -0.392 0.695044    
## as.factor(slide)5771710022 -0.050005   0.017835  -2.804 0.005346 ** 
## as.factor(slide)5771710023 -0.040079   0.018705  -2.143 0.032864 *  
## as.factor(slide)5771710036 -0.034243   0.019281  -1.776 0.076645 .  
## as.factor(slide)5771710037 -0.049806   0.019996  -2.491 0.013234 *  
## as.factor(slide)5771710038 -0.036598   0.019281  -1.898 0.058538 .  
## as.factor(slide)5806484004 -0.084768   0.019281  -4.397 1.48e-05 ***
## as.factor(slide)5806484008 -0.086536   0.019281  -4.488 9.91e-06 ***
## as.factor(slide)5806484010 -0.045794   0.023844  -1.921 0.055641 .  
## as.factor(slide)5806484023 -0.016196   0.026453  -0.612 0.540777    
## as.factor(slide)5806484024 -0.043980   0.018231  -2.412 0.016391 *  
## as.factor(slide)5806484056 -0.047759   0.019281  -2.477 0.013744 *  
## as.factor(slide)5806484057 -0.028300   0.019281  -1.468 0.143111    
## as.factor(slide)5806636054 -0.033821   0.041826  -0.809 0.419310    
## as.factor(slide)5815129004 -0.094502   0.017835  -5.299 2.12e-07 ***
## as.factor(slide)5815129009 -0.057800   0.017497  -3.303 0.001059 ** 
## as.factor(slide)5815129011 -0.039905   0.017835  -2.238 0.025913 *  
## as.factor(slide)5815129015 -0.073144   0.018231  -4.012 7.44e-05 ***
## as.factor(slide)5815129018 -0.067776   0.017497  -3.874 0.000129 ***
## as.factor(slide)5815129027 -0.058738   0.018231  -3.222 0.001400 ** 
## as.factor(slide)5815129028 -0.084362   0.017497  -4.822 2.17e-06 ***
## as.factor(slide)5815188011 -0.060006   0.019281  -3.112 0.002018 ** 
## as.factor(slide)5815188020 -0.047360   0.022132  -2.140 0.033092 *  
## as.factor(slide)5815188021 -0.035979   0.019281  -1.866 0.062915 .  
## as.factor(slide)5815188022 -0.031195   0.019996  -1.560 0.119700    
## as.factor(slide)5815188023 -0.016720   0.022132  -0.755 0.450495    
## as.factor(slide)6229009001 -0.177453   0.022132  -8.018 1.84e-14 ***
## as.factor(slide)6229009004 -0.125744   0.019281  -6.522 2.58e-10 ***
## as.factor(slide)6229009040 -0.047717   0.018705  -2.551 0.011188 *  
## as.factor(slide)6229009047 -0.081397   0.023844  -3.414 0.000720 ***
## as.factor(slide)6229009049 -0.063575   0.019996  -3.179 0.001615 ** 
## as.factor(slide)6229009050 -0.063924   0.018231  -3.506 0.000517 ***
## as.factor(slide)6229009056 -0.064106   0.022132  -2.897 0.004023 ** 
## as.factor(slide)6229009069 -0.007197   0.019281  -0.373 0.709199    
## as.factor(slide)6229009079 -0.058917   0.019996  -2.946 0.003442 ** 
## as.factor(slide)6229009080 -0.077864   0.020913  -3.723 0.000231 ***
## as.factor(slide)6229009083 -0.063969   0.022132  -2.890 0.004101 ** 
## as.factor(slide)6229009084 -0.027580   0.026453  -1.043 0.297891    
## as.factor(slide)6229009100 -0.085593   0.022132  -3.867 0.000132 ***
## as.factor(slide)6229009101 -0.082410   0.031019  -2.657 0.008269 ** 
## as.factor(slide)6229009106 -0.145262   0.041826  -3.473 0.000583 ***
## as.factor(slide)6229009107 -0.123861   0.031019  -3.993 8.03e-05 ***
## as.factor(slide)6229009112 -0.133149   0.020913  -6.367 6.40e-10 ***
## as.factor(slide)6229009147 -0.066930   0.041826  -1.600 0.110499    
## as.factor(slide)6229009151 -0.129381   0.023844  -5.426 1.11e-07 ***
## as.factor(slide)6229009153 -0.162275   0.041826  -3.880 0.000126 ***
## as.factor(slide)6229009162 -0.119896   0.018705  -6.410 4.98e-10 ***
## as.factor(slide)6229009166 -0.115572   0.031019  -3.726 0.000229 ***
## as.factor(slide)7810920047 -0.068048   0.031019  -2.194 0.028942 *  
## as.factor(slide)7810920048 -0.045675   0.023844  -1.916 0.056281 .  
## as.factor(slide)7810920075 -0.091971   0.022132  -4.156 4.13e-05 ***
## as.factor(slide)7810920088 -0.079150   0.026453  -2.992 0.002977 ** 
## as.factor(slide)7810920089 -0.062282   0.023844  -2.612 0.009408 ** 
## as.factor(slide)7810920091 -0.062013   0.022132  -2.802 0.005377 ** 
## as.factor(slide)7810920102 -0.046707   0.041826  -1.117 0.264923    
## as.factor(slide)7810920123 -0.065203   0.022132  -2.946 0.003445 ** 
## as.factor(slide)7810920128 -0.032997   0.041826  -0.789 0.430727    
## as.factor(slide)7810920166 -0.012220   0.041826  -0.292 0.770340    
## as.factor(slide)7810920178 -0.077918   0.041826  -1.863 0.063354 .  
## as.factor(slide)7927554017 -0.048646   0.031019  -1.568 0.117764    
## as.factor(slide)7927554041 -0.026134   0.041826  -0.625 0.532506    
## as.factor(slide)7927554078 -0.150605   0.031019  -4.855 1.85e-06 ***
## as.factor(slide)7927554080 -0.103543   0.031019  -3.338 0.000939 ***
## as.factor(slide)7927554092 -0.137463   0.041826  -3.287 0.001122 ** 
## as.factor(slide)7927554093 -0.104216   0.022132  -4.709 3.66e-06 ***
## as.factor(slide)7927554109 -0.077165   0.022132  -3.487 0.000555 ***
## as.factor(slide)7927554120 -0.075119   0.026453  -2.840 0.004793 ** 
## as.factor(slide)7927554124 -0.088653   0.019281  -4.598 6.07e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03968 on 333 degrees of freedom
## Multiple R-squared:  0.4757, Adjusted R-squared:  0.3671 
## F-statistic: 4.379 on 69 and 333 DF,  p-value: < 2.2e-16
summary(lm(PC1 ~ as.factor(slide), data = eigenvec_sd02_fetal_pheno))
## 
## Call:
## lm(formula = PC1 ~ as.factor(slide), data = eigenvec_sd02_fetal_pheno)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.46625 -0.01142  0.00092  0.03223  0.17634 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.12659    0.05598   2.262  0.03268 *  
## as.factor(slide)5815188023 -0.33501    0.07227  -4.636 9.58e-05 ***
## as.factor(slide)5815188024 -0.20407    0.07017  -2.908  0.00752 ** 
## as.factor(slide)5815188028 -0.15691    0.06856  -2.289  0.03082 *  
## as.factor(slide)6229009083 -0.13013    0.12517  -1.040  0.30846    
## as.factor(slide)6229009100  0.07049    0.12517   0.563  0.57833    
## as.factor(slide)6229009145  0.07191    0.07916   0.908  0.37236    
## as.factor(slide)6229009146  0.03978    0.09695   0.410  0.68510    
## as.factor(slide)6229009147  0.11730    0.12517   0.937  0.35765    
## as.factor(slide)7927554092 -0.16179    0.12517  -1.293  0.20798    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.112 on 25 degrees of freedom
## Multiple R-squared:  0.6867, Adjusted R-squared:  0.5739 
## F-statistic: 6.087 on 9 and 25 DF,  p-value: 0.0001596
summary(lm(PC1 ~ as.factor(slide), data = eigenvec_jaffe_sd02_pheno))
## 
## Call:
## lm(formula = PC1 ~ as.factor(slide), data = eigenvec_jaffe_sd02_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.149163 -0.007463 -0.001256  0.004578  0.139028 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 4.309e-03  7.885e-03   0.546  0.58504    
## as.factor(slide)5771710015 -1.040e-02  1.247e-02  -0.835  0.40444    
## as.factor(slide)5771710017 -1.334e-02  1.115e-02  -1.196  0.23233    
## as.factor(slide)5771710022 -1.833e-02  1.115e-02  -1.644  0.10092    
## as.factor(slide)5771710023 -1.604e-02  1.170e-02  -1.371  0.17095    
## as.factor(slide)5771710036 -1.260e-02  1.170e-02  -1.077  0.28199    
## as.factor(slide)5771710037 -1.251e-02  1.205e-02  -1.038  0.29972    
## as.factor(slide)5771710038 -1.586e-02  1.205e-02  -1.317  0.18858    
## as.factor(slide)5806484002  1.060e-02  1.577e-02   0.672  0.50183    
## as.factor(slide)5806484004 -1.591e-02  1.170e-02  -1.361  0.17430    
## as.factor(slide)5806484008 -1.015e-02  1.205e-02  -0.843  0.39990    
## as.factor(slide)5806484010  4.418e-02  1.115e-02   3.962 8.66e-05 ***
## as.factor(slide)5806484023 -5.115e-03  1.170e-02  -0.437  0.66206    
## as.factor(slide)5806484024 -1.639e-02  1.170e-02  -1.401  0.16179    
## as.factor(slide)5806484056 -1.918e-02  1.247e-02  -1.538  0.12474    
## as.factor(slide)5806484057 -1.268e-02  1.247e-02  -1.017  0.30975    
## as.factor(slide)5806636054 -6.796e-03  1.140e-02  -0.596  0.55147    
## as.factor(slide)5806636077 -1.032e-02  1.366e-02  -0.755  0.45041    
## as.factor(slide)5815129004 -2.024e-02  1.115e-02  -1.815  0.07025 .  
## as.factor(slide)5815129009 -2.004e-02  1.115e-02  -1.797  0.07304 .  
## as.factor(slide)5815129011 -1.904e-02  1.140e-02  -1.670  0.09560 .  
## as.factor(slide)5815129015 -1.919e-02  1.115e-02  -1.721  0.08597 .  
## as.factor(slide)5815129018 -2.255e-02  1.115e-02  -2.022  0.04377 *  
## as.factor(slide)5815129027 -2.020e-02  1.140e-02  -1.772  0.07713 .  
## as.factor(slide)5815129028 -2.051e-02  1.115e-02  -1.839  0.06655 .  
## as.factor(slide)5815188010 -6.376e-03  1.454e-02  -0.439  0.66121    
## as.factor(slide)5815188011 -8.841e-03  1.170e-02  -0.756  0.45012    
## as.factor(slide)5815188020 -6.266e-03  1.140e-02  -0.550  0.58293    
## as.factor(slide)5815188021 -1.390e-02  1.205e-02  -1.154  0.24901    
## as.factor(slide)5815188022 -6.887e-03  1.299e-02  -0.530  0.59628    
## as.factor(slide)5815188023  6.888e-02  1.115e-02   6.177 1.46e-09 ***
## as.factor(slide)5815188024  1.524e-01  1.299e-02  11.729  < 2e-16 ***
## as.factor(slide)5815188028  1.330e-01  1.205e-02  11.045  < 2e-16 ***
## as.factor(slide)6229009001 -1.826e-02  1.299e-02  -1.405  0.16065    
## as.factor(slide)6229009004 -2.558e-02  1.247e-02  -2.051  0.04081 *  
## as.factor(slide)6229009040 -2.148e-02  1.170e-02  -1.836  0.06699 .  
## as.factor(slide)6229009047 -2.554e-02  1.577e-02  -1.620  0.10600    
## as.factor(slide)6229009049 -2.040e-02  1.299e-02  -1.570  0.11712    
## as.factor(slide)6229009050 -2.272e-02  1.140e-02  -1.992  0.04693 *  
## as.factor(slide)6229009056 -1.979e-02  1.454e-02  -1.361  0.17421    
## as.factor(slide)6229009069 -9.644e-03  1.247e-02  -0.774  0.43963    
## as.factor(slide)6229009079 -1.870e-02  1.299e-02  -1.439  0.15082    
## as.factor(slide)6229009080 -2.311e-02  1.366e-02  -1.692  0.09126 .  
## as.factor(slide)6229009083  3.335e-03  1.366e-02   0.244  0.80722    
## as.factor(slide)6229009084 -1.999e-02  1.763e-02  -1.134  0.25744    
## as.factor(slide)6229009100  4.042e-03  1.247e-02   0.324  0.74596    
## as.factor(slide)6229009101 -2.815e-02  2.086e-02  -1.350  0.17785    
## as.factor(slide)6229009106 -3.484e-02  2.843e-02  -1.225  0.22108    
## as.factor(slide)6229009107 -1.889e-02  1.763e-02  -1.071  0.28460    
## as.factor(slide)6229009112 -2.767e-02  1.366e-02  -2.026  0.04340 *  
## as.factor(slide)6229009145  1.413e-01  1.577e-02   8.957  < 2e-16 ***
## as.factor(slide)6229009146  1.032e-01  1.763e-02   5.855 9.24e-09 ***
## as.factor(slide)6229009147  4.306e-02  1.763e-02   2.442  0.01497 *  
## as.factor(slide)6229009151 -3.093e-02  1.577e-02  -1.961  0.05050 .  
## as.factor(slide)6229009153 -3.727e-02  2.843e-02  -1.311  0.19051    
## as.factor(slide)6229009162 -2.889e-02  1.205e-02  -2.399  0.01687 *  
## as.factor(slide)6229009166 -2.306e-02  2.086e-02  -1.105  0.26958    
## as.factor(slide)7810920047  2.962e-02  1.763e-02   1.680  0.09370 .  
## as.factor(slide)7810920048  6.199e-03  1.366e-02   0.454  0.65014    
## as.factor(slide)7810920075 -1.857e-02  1.454e-02  -1.277  0.20231    
## as.factor(slide)7810920088 -2.285e-02  1.577e-02  -1.449  0.14808    
## as.factor(slide)7810920089 -2.028e-02  1.577e-02  -1.286  0.19921    
## as.factor(slide)7810920091 -2.163e-02  1.366e-02  -1.584  0.11396    
## as.factor(slide)7810920102 -2.121e-02  2.843e-02  -0.746  0.45612    
## as.factor(slide)7810920123 -1.540e-02  1.454e-02  -1.059  0.29012    
## as.factor(slide)7810920128  1.799e-02  1.299e-02   1.385  0.16683    
## as.factor(slide)7810920166 -4.407e-05  1.763e-02  -0.002  0.99801    
## as.factor(slide)7810920178 -2.005e-02  2.843e-02  -0.705  0.48111    
## as.factor(slide)7927554017 -2.005e-02  2.086e-02  -0.961  0.33695    
## as.factor(slide)7927554041 -2.010e-02  2.843e-02  -0.707  0.47998    
## as.factor(slide)7927554078 -2.126e-02  2.086e-02  -1.019  0.30869    
## as.factor(slide)7927554080 -2.356e-02  2.086e-02  -1.129  0.25937    
## as.factor(slide)7927554092  5.714e-02  2.086e-02   2.739  0.00641 ** 
## as.factor(slide)7927554093 -2.243e-02  1.454e-02  -1.543  0.12354    
## as.factor(slide)7927554109 -1.836e-02  1.454e-02  -1.263  0.20724    
## as.factor(slide)7927554120 -2.006e-02  1.577e-02  -1.272  0.20414    
## as.factor(slide)7927554124 -2.369e-02  1.247e-02  -1.900  0.05808 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02732 on 449 degrees of freedom
## Multiple R-squared:  0.665,  Adjusted R-squared:  0.6083 
## F-statistic: 11.73 on 76 and 449 DF,  p-value: < 2.2e-16

PC2

summary(lm(PC2 ~ as.factor(slide), data = eigenvec_sd02_pheno))
## 
## Call:
## lm(formula = PC2 ~ as.factor(slide), data = eigenvec_sd02_pheno)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.12277 -0.01761  0.00000  0.01631  0.11715 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.045394   0.008560   5.303 1.82e-07 ***
## as.factor(slide)5771710015 -0.001431   0.013534  -0.106 0.915838    
## as.factor(slide)5771710017  0.010041   0.012105   0.829 0.407313    
## as.factor(slide)5771710022 -0.023604   0.012105  -1.950 0.051830 .  
## as.factor(slide)5771710023 -0.014305   0.012696  -1.127 0.260487    
## as.factor(slide)5771710036 -0.018410   0.012696  -1.450 0.147773    
## as.factor(slide)5771710037 -0.027538   0.013075  -2.106 0.035768 *  
## as.factor(slide)5771710038 -0.022456   0.013075  -1.717 0.086608 .  
## as.factor(slide)5806484002 -0.017319   0.017120  -1.012 0.312270    
## as.factor(slide)5806484004 -0.056258   0.012696  -4.431 1.19e-05 ***
## as.factor(slide)5806484008 -0.091247   0.013075  -6.979 1.12e-11 ***
## as.factor(slide)5806484010 -0.061455   0.012377  -4.965 9.89e-07 ***
## as.factor(slide)5806484023 -0.022598   0.012696  -1.780 0.075787 .  
## as.factor(slide)5806484024 -0.023699   0.012696  -1.867 0.062627 .  
## as.factor(slide)5806484056 -0.015798   0.013534  -1.167 0.243748    
## as.factor(slide)5806484057 -0.016145   0.013534  -1.193 0.233558    
## as.factor(slide)5806636054 -0.031438   0.012377  -2.540 0.011434 *  
## as.factor(slide)5806636077 -0.033518   0.014826  -2.261 0.024269 *  
## as.factor(slide)5815129004 -0.077801   0.012105  -6.427 3.43e-10 ***
## as.factor(slide)5815129009 -0.036191   0.012105  -2.990 0.002952 ** 
## as.factor(slide)5815129011 -0.021314   0.012377  -1.722 0.085776 .  
## as.factor(slide)5815129015 -0.052966   0.012377  -4.279 2.31e-05 ***
## as.factor(slide)5815129018 -0.034681   0.012105  -2.865 0.004374 ** 
## as.factor(slide)5815129027 -0.032608   0.012696  -2.568 0.010553 *  
## as.factor(slide)5815129028 -0.060478   0.012377  -4.886 1.45e-06 ***
## as.factor(slide)5815188010 -0.018540   0.030863  -0.601 0.548347    
## as.factor(slide)5815188011 -0.039543   0.012696  -3.115 0.001964 ** 
## as.factor(slide)5815188020 -0.034262   0.012377  -2.768 0.005880 ** 
## as.factor(slide)5815188021 -0.023960   0.013075  -1.832 0.067568 .  
## as.factor(slide)5815188022 -0.021160   0.014102  -1.500 0.134220    
## as.factor(slide)5815188023 -0.043700   0.012105  -3.610 0.000342 ***
## as.factor(slide)5815188024 -0.078315   0.014102  -5.553 4.89e-08 ***
## as.factor(slide)5815188028 -0.085330   0.013075  -6.526 1.89e-10 ***
## as.factor(slide)6229009001 -0.218312   0.014826 -14.725  < 2e-16 ***
## as.factor(slide)6229009004 -0.117023   0.013534  -8.646  < 2e-16 ***
## as.factor(slide)6229009040 -0.028486   0.013075  -2.179 0.029899 *  
## as.factor(slide)6229009047 -0.055598   0.017120  -3.248 0.001254 ** 
## as.factor(slide)6229009049 -0.038288   0.014102  -2.715 0.006892 ** 
## as.factor(slide)6229009050 -0.037358   0.012377  -3.018 0.002692 ** 
## as.factor(slide)6229009056 -0.040543   0.015783  -2.569 0.010542 *  
## as.factor(slide)6229009069 -0.008968   0.013534  -0.663 0.507951    
## as.factor(slide)6229009079 -0.035444   0.014102  -2.513 0.012320 *  
## as.factor(slide)6229009080 -0.045240   0.014826  -3.051 0.002418 ** 
## as.factor(slide)6229009083 -0.041079   0.015783  -2.603 0.009567 ** 
## as.factor(slide)6229009084 -0.007602   0.019140  -0.397 0.691420    
## as.factor(slide)6229009100 -0.065820   0.014102  -4.667 4.07e-06 ***
## as.factor(slide)6229009101 -0.055733   0.022647  -2.461 0.014245 *  
## as.factor(slide)6229009106 -0.136138   0.030863  -4.411 1.30e-05 ***
## as.factor(slide)6229009107 -0.112246   0.019140  -5.864 8.94e-09 ***
## as.factor(slide)6229009112 -0.101766   0.014826  -6.864 2.32e-11 ***
## as.factor(slide)6229009145 -0.103019   0.019140  -5.382 1.21e-07 ***
## as.factor(slide)6229009146 -0.100982   0.022647  -4.459 1.05e-05 ***
## as.factor(slide)6229009147 -0.081549   0.019140  -4.261 2.50e-05 ***
## as.factor(slide)6229009151 -0.108933   0.017120  -6.363 5.03e-10 ***
## as.factor(slide)6229009153 -0.118494   0.030863  -3.839 0.000142 ***
## as.factor(slide)6229009162 -0.102685   0.013075  -7.853 3.21e-14 ***
## as.factor(slide)6229009166 -0.122516   0.022647  -5.410 1.04e-07 ***
## as.factor(slide)7810920047 -0.067526   0.019140  -3.528 0.000463 ***
## as.factor(slide)7810920048 -0.055229   0.014826  -3.725 0.000221 ***
## as.factor(slide)7810920075 -0.065382   0.015783  -4.142 4.13e-05 ***
## as.factor(slide)7810920088 -0.044253   0.019140  -2.312 0.021243 *  
## as.factor(slide)7810920089 -0.029259   0.017120  -1.709 0.088149 .  
## as.factor(slide)7810920091 -0.021457   0.014826  -1.447 0.148544    
## as.factor(slide)7810920102 -0.001764   0.030863  -0.057 0.954455    
## as.factor(slide)7810920123 -0.026481   0.015783  -1.678 0.094110 .  
## as.factor(slide)7810920128 -0.047474   0.014102  -3.366 0.000829 ***
## as.factor(slide)7810920166 -0.039417   0.019140  -2.059 0.040053 *  
## as.factor(slide)7810920178 -0.047377   0.030863  -1.535 0.125489    
## as.factor(slide)7927554017 -0.020681   0.022647  -0.913 0.361646    
## as.factor(slide)7927554041  0.002507   0.030863   0.081 0.935285    
## as.factor(slide)7927554078 -0.110175   0.022647  -4.865 1.61e-06 ***
## as.factor(slide)7927554080 -0.068748   0.022647  -3.036 0.002545 ** 
## as.factor(slide)7927554092 -0.064452   0.022647  -2.846 0.004638 ** 
## as.factor(slide)7927554093 -0.075562   0.015783  -4.787 2.32e-06 ***
## as.factor(slide)7927554109 -0.049962   0.015783  -3.165 0.001657 ** 
## as.factor(slide)7927554120 -0.060889   0.017120  -3.557 0.000417 ***
## as.factor(slide)7927554124 -0.054213   0.013534  -4.006 7.28e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02965 on 434 degrees of freedom
## Multiple R-squared:  0.6184, Adjusted R-squared:  0.5516 
## F-statistic: 9.255 on 76 and 434 DF,  p-value: < 2.2e-16
summary(lm(PC2 ~ as.factor(slide), data = eigenvec_sd02_age18_pheno))
## 
## Call:
## lm(formula = PC2 ~ as.factor(slide), data = eigenvec_sd02_age18_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.106354 -0.017778  0.000111  0.020817  0.114419 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.0057427  0.0116932   0.491 0.623667    
## as.factor(slide)5771710015  0.0353702  0.0176784   2.001 0.046230 *  
## as.factor(slide)5771710017  0.0158064  0.0154686   1.022 0.307600    
## as.factor(slide)5771710022  0.0240569  0.0157671   1.526 0.128017    
## as.factor(slide)5771710023  0.0312055  0.0165366   1.887 0.060023 .  
## as.factor(slide)5771710036  0.0189482  0.0170456   1.112 0.267103    
## as.factor(slide)5771710037  0.0296239  0.0176784   1.676 0.094733 .  
## as.factor(slide)5771710038  0.0223664  0.0170456   1.312 0.190373    
## as.factor(slide)5806484004  0.0123570  0.0170456   0.725 0.469001    
## as.factor(slide)5806484008 -0.1022682  0.0170456  -6.000 5.16e-09 ***
## as.factor(slide)5806484010 -0.0249307  0.0210802  -1.183 0.237787    
## as.factor(slide)5806484023 -0.0275811  0.0233864  -1.179 0.239093    
## as.factor(slide)5806484024  0.0003323  0.0161179   0.021 0.983565    
## as.factor(slide)5806484056  0.0331788  0.0170456   1.946 0.052439 .  
## as.factor(slide)5806484057 -0.0197901  0.0170456  -1.161 0.246470    
## as.factor(slide)5806636054  0.0236905  0.0369771   0.641 0.522171    
## as.factor(slide)5815129004 -0.0396898  0.0157671  -2.517 0.012296 *  
## as.factor(slide)5815129009 -0.0090931  0.0154686  -0.588 0.557037    
## as.factor(slide)5815129011 -0.0001110  0.0157671  -0.007 0.994385    
## as.factor(slide)5815129015  0.0068718  0.0161179   0.426 0.670133    
## as.factor(slide)5815129018  0.0194132  0.0154686   1.255 0.210357    
## as.factor(slide)5815129027  0.0038878  0.0161179   0.241 0.809539    
## as.factor(slide)5815129028 -0.0200103  0.0154686  -1.294 0.196698    
## as.factor(slide)5815188011  0.0146889  0.0170456   0.862 0.389448    
## as.factor(slide)5815188020  0.0046034  0.0195664   0.235 0.814145    
## as.factor(slide)5815188021 -0.0041185  0.0170456  -0.242 0.809227    
## as.factor(slide)5815188022 -0.0099740  0.0176784  -0.564 0.573003    
## as.factor(slide)5815188023  0.0090957  0.0195664   0.465 0.642333    
## as.factor(slide)6229009001 -0.1714090  0.0195664  -8.760  < 2e-16 ***
## as.factor(slide)6229009004 -0.0845446  0.0170456  -4.960 1.13e-06 ***
## as.factor(slide)6229009040 -0.0042174  0.0165366  -0.255 0.798854    
## as.factor(slide)6229009047 -0.0076481  0.0210802  -0.363 0.716975    
## as.factor(slide)6229009049 -0.0029501  0.0176784  -0.167 0.867569    
## as.factor(slide)6229009050  0.0067622  0.0161179   0.420 0.675086    
## as.factor(slide)6229009056  0.0047499  0.0195664   0.243 0.808343    
## as.factor(slide)6229009069 -0.0443270  0.0170456  -2.600 0.009724 ** 
## as.factor(slide)6229009079 -0.0015867  0.0176784  -0.090 0.928537    
## as.factor(slide)6229009080  0.0126600  0.0184885   0.685 0.493980    
## as.factor(slide)6229009083  0.0003908  0.0195664   0.020 0.984075    
## as.factor(slide)6229009084 -0.0032465  0.0233864  -0.139 0.889675    
## as.factor(slide)6229009100 -0.0142572  0.0195664  -0.729 0.466725    
## as.factor(slide)6229009101 -0.0403161  0.0274229  -1.470 0.142463    
## as.factor(slide)6229009106 -0.1297667  0.0369771  -3.509 0.000511 ***
## as.factor(slide)6229009107 -0.0634423  0.0274229  -2.313 0.021305 *  
## as.factor(slide)6229009112 -0.0351226  0.0184885  -1.900 0.058337 .  
## as.factor(slide)6229009147 -0.0659723  0.0369771  -1.784 0.075311 .  
## as.factor(slide)6229009151 -0.0815907  0.0210802  -3.870 0.000131 ***
## as.factor(slide)6229009153 -0.0441296  0.0369771  -1.193 0.233550    
## as.factor(slide)6229009162 -0.0738934  0.0165366  -4.468 1.08e-05 ***
## as.factor(slide)6229009166 -0.1403997  0.0274229  -5.120 5.18e-07 ***
## as.factor(slide)7810920047 -0.0654330  0.0274229  -2.386 0.017588 *  
## as.factor(slide)7810920048  0.0001848  0.0210802   0.009 0.993011    
## as.factor(slide)7810920075 -0.0043378  0.0195664  -0.222 0.824688    
## as.factor(slide)7810920088  0.0204174  0.0233864   0.873 0.383265    
## as.factor(slide)7810920089  0.0276463  0.0210802   1.311 0.190598    
## as.factor(slide)7810920091  0.0349518  0.0195664   1.786 0.074958 .  
## as.factor(slide)7810920102  0.0519857  0.0369771   1.406 0.160689    
## as.factor(slide)7810920123  0.0421237  0.0195664   2.153 0.032048 *  
## as.factor(slide)7810920128  0.0542779  0.0369771   1.468 0.143081    
## as.factor(slide)7810920166  0.0096550  0.0369771   0.261 0.794171    
## as.factor(slide)7810920178  0.0233002  0.0369771   0.630 0.529045    
## as.factor(slide)7927554017  0.0215758  0.0274229   0.787 0.431970    
## as.factor(slide)7927554041  0.0354718  0.0369771   0.959 0.338108    
## as.factor(slide)7927554078  0.0199105  0.0274229   0.726 0.468317    
## as.factor(slide)7927554080  0.0212687  0.0274229   0.776 0.438547    
## as.factor(slide)7927554092  0.0721127  0.0369771   1.950 0.051991 .  
## as.factor(slide)7927554093  0.0054606  0.0195664   0.279 0.780357    
## as.factor(slide)7927554109  0.0147712  0.0195664   0.755 0.450826    
## as.factor(slide)7927554120  0.0181893  0.0233864   0.778 0.437255    
## as.factor(slide)7927554124  0.0241113  0.0170456   1.415 0.158145    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03508 on 333 degrees of freedom
## Multiple R-squared:  0.5902, Adjusted R-squared:  0.5053 
## F-statistic: 6.951 on 69 and 333 DF,  p-value: < 2.2e-16
summary(lm(PC2 ~ as.factor(slide), data = eigenvec_sd02_fetal_pheno))
## 
## Call:
## lm(formula = PC2 ~ as.factor(slide), data = eigenvec_sd02_fetal_pheno)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.57165 -0.00878  0.01482  0.04218  0.20740 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)  
## (Intercept)                -0.03228    0.07317  -0.441   0.6629  
## as.factor(slide)5815188023  0.02357    0.09447   0.250   0.8050  
## as.factor(slide)5815188024  0.17340    0.09173   1.890   0.0704 .
## as.factor(slide)5815188028  0.11008    0.08962   1.228   0.2308  
## as.factor(slide)6229009083  0.04253    0.16362   0.260   0.7970  
## as.factor(slide)6229009100 -0.07008    0.16362  -0.428   0.6721  
## as.factor(slide)6229009145 -0.18682    0.10349  -1.805   0.0831 .
## as.factor(slide)6229009146 -0.13014    0.12674  -1.027   0.3144  
## as.factor(slide)6229009147 -0.09697    0.16362  -0.593   0.5587  
## as.factor(slide)7927554092  0.02602    0.16362   0.159   0.8749  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1463 on 25 degrees of freedom
## Multiple R-squared:  0.4645, Adjusted R-squared:  0.2718 
## F-statistic:  2.41 on 9 and 25 DF,  p-value: 0.03987
summary(lm(PC2 ~ as.factor(slide), data = eigenvec_jaffe_sd02_pheno))
## 
## Call:
## lm(formula = PC2 ~ as.factor(slide), data = eigenvec_jaffe_sd02_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.092434 -0.018450 -0.001394  0.017459  0.094847 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.037745   0.008818   4.280 2.28e-05 ***
## as.factor(slide)5771710015 -0.005209   0.013943  -0.374 0.708904    
## as.factor(slide)5771710017  0.013345   0.012471   1.070 0.285166    
## as.factor(slide)5771710022 -0.016545   0.012471  -1.327 0.185284    
## as.factor(slide)5771710023 -0.012253   0.013080  -0.937 0.349356    
## as.factor(slide)5771710036 -0.013858   0.013080  -1.059 0.289949    
## as.factor(slide)5771710037 -0.019374   0.013470  -1.438 0.151042    
## as.factor(slide)5771710038 -0.017525   0.013470  -1.301 0.193908    
## as.factor(slide)5806484002 -0.023236   0.017637  -1.317 0.188346    
## as.factor(slide)5806484004 -0.053720   0.013080  -4.107 4.76e-05 ***
## as.factor(slide)5806484008 -0.095367   0.013470  -7.080 5.59e-12 ***
## as.factor(slide)5806484010 -0.044799   0.012471  -3.592 0.000364 ***
## as.factor(slide)5806484023 -0.013220   0.013080  -1.011 0.312694    
## as.factor(slide)5806484024 -0.017537   0.013080  -1.341 0.180673    
## as.factor(slide)5806484056 -0.016324   0.013943  -1.171 0.242315    
## as.factor(slide)5806484057 -0.006359   0.013943  -0.456 0.648559    
## as.factor(slide)5806636054 -0.033001   0.012751  -2.588 0.009964 ** 
## as.factor(slide)5806636077 -0.021630   0.015274  -1.416 0.157425    
## as.factor(slide)5815129004 -0.068774   0.012471  -5.515 5.91e-08 ***
## as.factor(slide)5815129009 -0.030991   0.012471  -2.485 0.013318 *  
## as.factor(slide)5815129011 -0.010930   0.012751  -0.857 0.391824    
## as.factor(slide)5815129015 -0.046447   0.012471  -3.724 0.000221 ***
## as.factor(slide)5815129018 -0.027913   0.012471  -2.238 0.025694 *  
## as.factor(slide)5815129027 -0.025286   0.012751  -1.983 0.047973 *  
## as.factor(slide)5815129028 -0.049839   0.012471  -3.996 7.52e-05 ***
## as.factor(slide)5815188010 -0.013546   0.016260  -0.833 0.405246    
## as.factor(slide)5815188011 -0.028129   0.013080  -2.151 0.032043 *  
## as.factor(slide)5815188020 -0.020577   0.012751  -1.614 0.107282    
## as.factor(slide)5815188021 -0.012145   0.013470  -0.902 0.367749    
## as.factor(slide)5815188022  0.003600   0.014528   0.248 0.804416    
## as.factor(slide)5815188023 -0.019223   0.012471  -1.541 0.123920    
## as.factor(slide)5815188024 -0.031193   0.014528  -2.147 0.032322 *  
## as.factor(slide)5815188028 -0.044082   0.013470  -3.273 0.001148 ** 
## as.factor(slide)6229009001 -0.160322   0.014528 -11.035  < 2e-16 ***
## as.factor(slide)6229009004 -0.102878   0.013943  -7.378 7.81e-13 ***
## as.factor(slide)6229009040 -0.023312   0.013080  -1.782 0.075377 .  
## as.factor(slide)6229009047 -0.045183   0.017637  -2.562 0.010735 *  
## as.factor(slide)6229009049 -0.031654   0.014528  -2.179 0.029866 *  
## as.factor(slide)6229009050 -0.037868   0.012751  -2.970 0.003140 ** 
## as.factor(slide)6229009056 -0.032153   0.016260  -1.977 0.048603 *  
## as.factor(slide)6229009069  0.006128   0.013943   0.440 0.660509    
## as.factor(slide)6229009079 -0.029382   0.014528  -2.022 0.043724 *  
## as.factor(slide)6229009080 -0.040086   0.015274  -2.625 0.008973 ** 
## as.factor(slide)6229009083 -0.033171   0.015274  -2.172 0.030394 *  
## as.factor(slide)6229009084 -0.015098   0.019718  -0.766 0.444263    
## as.factor(slide)6229009100 -0.075171   0.013943  -5.391 1.13e-07 ***
## as.factor(slide)6229009101 -0.088973   0.023331  -3.814 0.000156 ***
## as.factor(slide)6229009106 -0.161435   0.031795  -5.077 5.62e-07 ***
## as.factor(slide)6229009107 -0.125716   0.019718  -6.376 4.53e-10 ***
## as.factor(slide)6229009112 -0.120263   0.015274  -7.874 2.61e-14 ***
## as.factor(slide)6229009145 -0.095863   0.017637  -5.435 8.99e-08 ***
## as.factor(slide)6229009146 -0.101096   0.019718  -5.127 4.38e-07 ***
## as.factor(slide)6229009147 -0.075567   0.019718  -3.832 0.000145 ***
## as.factor(slide)6229009151 -0.100613   0.017637  -5.705 2.12e-08 ***
## as.factor(slide)6229009153 -0.134742   0.031795  -4.238 2.74e-05 ***
## as.factor(slide)6229009162 -0.111447   0.013470  -8.274 1.49e-15 ***
## as.factor(slide)6229009166 -0.116997   0.023331  -5.015 7.66e-07 ***
## as.factor(slide)7810920047 -0.058911   0.019718  -2.988 0.002966 ** 
## as.factor(slide)7810920048 -0.034371   0.015274  -2.250 0.024909 *  
## as.factor(slide)7810920075 -0.044331   0.016260  -2.726 0.006654 ** 
## as.factor(slide)7810920088 -0.040017   0.017637  -2.269 0.023742 *  
## as.factor(slide)7810920089 -0.026655   0.017637  -1.511 0.131406    
## as.factor(slide)7810920091 -0.026652   0.015274  -1.745 0.081672 .  
## as.factor(slide)7810920102 -0.009273   0.031795  -0.292 0.770691    
## as.factor(slide)7810920123 -0.030630   0.016260  -1.884 0.060249 .  
## as.factor(slide)7810920128 -0.041705   0.014528  -2.871 0.004290 ** 
## as.factor(slide)7810920166 -0.036713   0.019718  -1.862 0.063274 .  
## as.factor(slide)7810920178 -0.042792   0.031795  -1.346 0.179020    
## as.factor(slide)7927554017 -0.017348   0.023331  -0.744 0.457527    
## as.factor(slide)7927554041  0.003204   0.031795   0.101 0.919772    
## as.factor(slide)7927554078 -0.091016   0.023331  -3.901 0.000110 ***
## as.factor(slide)7927554080 -0.055330   0.023331  -2.372 0.018135 *  
## as.factor(slide)7927554092 -0.053741   0.023331  -2.303 0.021713 *  
## as.factor(slide)7927554093 -0.054439   0.016260  -3.348 0.000882 ***
## as.factor(slide)7927554109 -0.038074   0.016260  -2.342 0.019639 *  
## as.factor(slide)7927554120 -0.036922   0.017637  -2.094 0.036865 *  
## as.factor(slide)7927554124 -0.046802   0.013943  -3.357 0.000856 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03055 on 449 degrees of freedom
## Multiple R-squared:  0.581,  Adjusted R-squared:  0.5101 
## F-statistic: 8.193 on 76 and 449 DF,  p-value: < 2.2e-16

PC3

summary(lm(PC3 ~ as.factor(slide), data = eigenvec_sd02_pheno))
## 
## Call:
## lm(formula = PC3 ~ as.factor(slide), data = eigenvec_sd02_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.083722 -0.023321 -0.001714  0.019326  0.121817 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                -0.0011188  0.0108702  -0.103 0.918072    
## as.factor(slide)5771710015 -0.0173928  0.0171873  -1.012 0.312123    
## as.factor(slide)5771710017  0.0035243  0.0153728   0.229 0.818777    
## as.factor(slide)5771710022 -0.0195257  0.0153728  -1.270 0.204711    
## as.factor(slide)5771710023 -0.0233872  0.0161231  -1.451 0.147630    
## as.factor(slide)5771710036 -0.0237666  0.0161231  -1.474 0.141187    
## as.factor(slide)5771710037 -0.0268992  0.0166045  -1.620 0.105960    
## as.factor(slide)5771710038 -0.0227048  0.0166045  -1.367 0.172211    
## as.factor(slide)5806484002 -0.0505638  0.0217404  -2.326 0.020489 *  
## as.factor(slide)5806484004 -0.0226809  0.0161231  -1.407 0.160222    
## as.factor(slide)5806484008  0.0683983  0.0166045   4.119 4.55e-05 ***
## as.factor(slide)5806484010  0.0090152  0.0157183   0.574 0.566571    
## as.factor(slide)5806484023  0.0069352  0.0161231   0.430 0.667307    
## as.factor(slide)5806484024  0.0067073  0.0161231   0.416 0.677610    
## as.factor(slide)5806484056 -0.0178235  0.0171873  -1.037 0.300305    
## as.factor(slide)5806484057  0.0274632  0.0171873   1.598 0.110798    
## as.factor(slide)5806636054 -0.0122690  0.0157183  -0.781 0.435489    
## as.factor(slide)5806636077 -0.0282518  0.0188277  -1.501 0.134201    
## as.factor(slide)5815129004  0.0294935  0.0153728   1.919 0.055696 .  
## as.factor(slide)5815129009  0.0118959  0.0153728   0.774 0.439453    
## as.factor(slide)5815129011  0.0107789  0.0157183   0.686 0.493232    
## as.factor(slide)5815129015 -0.0055758  0.0157183  -0.355 0.722962    
## as.factor(slide)5815129018 -0.0115064  0.0153728  -0.748 0.454570    
## as.factor(slide)5815129027  0.0010366  0.0161231   0.064 0.948768    
## as.factor(slide)5815129028  0.0155098  0.0157183   0.987 0.324321    
## as.factor(slide)5815188010  0.0503012  0.0391930   1.283 0.200029    
## as.factor(slide)5815188011 -0.0177450  0.0161231  -1.101 0.271684    
## as.factor(slide)5815188020 -0.0075644  0.0157183  -0.481 0.630581    
## as.factor(slide)5815188021  0.0034840  0.0166045   0.210 0.833905    
## as.factor(slide)5815188022  0.0207116  0.0179087   1.157 0.248110    
## as.factor(slide)5815188023  0.0018735  0.0153728   0.122 0.903058    
## as.factor(slide)5815188024  0.0105281  0.0179087   0.588 0.556921    
## as.factor(slide)5815188028  0.0112877  0.0166045   0.680 0.496994    
## as.factor(slide)6229009001  0.1087603  0.0188277   5.777 1.46e-08 ***
## as.factor(slide)6229009004  0.0474644  0.0171873   2.762 0.005996 ** 
## as.factor(slide)6229009040  0.0066216  0.0166045   0.399 0.690251    
## as.factor(slide)6229009047  0.0035095  0.0217404   0.161 0.871832    
## as.factor(slide)6229009049  0.0039354  0.0179087   0.220 0.826170    
## as.factor(slide)6229009050 -0.0093722  0.0157183  -0.596 0.551310    
## as.factor(slide)6229009056 -0.0067579  0.0200436  -0.337 0.736161    
## as.factor(slide)6229009069  0.0536302  0.0171873   3.120 0.001927 ** 
## as.factor(slide)6229009079  0.0036380  0.0179087   0.203 0.839120    
## as.factor(slide)6229009080 -0.0130692  0.0188277  -0.694 0.487963    
## as.factor(slide)6229009083  0.0008821  0.0200436   0.044 0.964917    
## as.factor(slide)6229009084  0.0143932  0.0243065   0.592 0.554056    
## as.factor(slide)6229009100  0.0033544  0.0179087   0.187 0.851510    
## as.factor(slide)6229009101  0.0320777  0.0287598   1.115 0.265311    
## as.factor(slide)6229009106  0.0905745  0.0391930   2.311 0.021302 *  
## as.factor(slide)6229009107  0.0097972  0.0243065   0.403 0.687096    
## as.factor(slide)6229009112  0.0037691  0.0188277   0.200 0.841425    
## as.factor(slide)6229009145  0.0334721  0.0243065   1.377 0.169196    
## as.factor(slide)6229009146 -0.0039261  0.0287598  -0.137 0.891480    
## as.factor(slide)6229009147  0.0405623  0.0243065   1.669 0.095882 .  
## as.factor(slide)6229009151  0.0512704  0.0217404   2.358 0.018801 *  
## as.factor(slide)6229009153  0.0149629  0.0391930   0.382 0.702816    
## as.factor(slide)6229009162  0.0468917  0.0166045   2.824 0.004961 ** 
## as.factor(slide)6229009166  0.0972518  0.0287598   3.382 0.000786 ***
## as.factor(slide)7810920047  0.0224149  0.0243065   0.922 0.356949    
## as.factor(slide)7810920048 -0.0125681  0.0188277  -0.668 0.504787    
## as.factor(slide)7810920075 -0.0063961  0.0200436  -0.319 0.749797    
## as.factor(slide)7810920088 -0.0243124  0.0243065  -1.000 0.317749    
## as.factor(slide)7810920089 -0.0239047  0.0217404  -1.100 0.272136    
## as.factor(slide)7810920091 -0.0347105  0.0188277  -1.844 0.065925 .  
## as.factor(slide)7810920102 -0.0271506  0.0391930  -0.693 0.488843    
## as.factor(slide)7810920123 -0.0343849  0.0200436  -1.716 0.086967 .  
## as.factor(slide)7810920128 -0.0543430  0.0179087  -3.034 0.002555 ** 
## as.factor(slide)7810920166 -0.0522474  0.0243065  -2.150 0.032145 *  
## as.factor(slide)7810920178 -0.0283403  0.0391930  -0.723 0.470011    
## as.factor(slide)7927554017 -0.0099782  0.0287598  -0.347 0.728799    
## as.factor(slide)7927554041 -0.0152087  0.0391930  -0.388 0.698172    
## as.factor(slide)7927554078 -0.0483650  0.0287598  -1.682 0.093349 .  
## as.factor(slide)7927554080 -0.0294344  0.0287598  -1.023 0.306663    
## as.factor(slide)7927554092 -0.0384697  0.0287598  -1.338 0.181722    
## as.factor(slide)7927554093 -0.0136951  0.0200436  -0.683 0.494804    
## as.factor(slide)7927554109 -0.0163036  0.0200436  -0.813 0.416431    
## as.factor(slide)7927554120 -0.0057948  0.0217404  -0.267 0.789944    
## as.factor(slide)7927554124 -0.0266722  0.0171873  -1.552 0.121426    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03766 on 434 degrees of freedom
## Multiple R-squared:  0.3846, Adjusted R-squared:  0.2769 
## F-statistic: 3.569 on 76 and 434 DF,  p-value: < 2.2e-16
summary(lm(PC3 ~ as.factor(slide), data = eigenvec_sd02_age18_pheno))
## 
## Call:
## lm(formula = PC3 ~ as.factor(slide), data = eigenvec_sd02_age18_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.118718 -0.009969  0.000000  0.008636  0.118771 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                -0.0206769  0.0067848  -3.048 0.002492 ** 
## as.factor(slide)5771710015  0.0027479  0.0102576   0.268 0.788949    
## as.factor(slide)5771710017  0.0026960  0.0089754   0.300 0.764077    
## as.factor(slide)5771710022  0.0009628  0.0091486   0.105 0.916246    
## as.factor(slide)5771710023 -0.0075201  0.0095951  -0.784 0.433750    
## as.factor(slide)5771710036 -0.0001704  0.0098904  -0.017 0.986266    
## as.factor(slide)5771710037  0.0044342  0.0102576   0.432 0.665811    
## as.factor(slide)5771710038 -0.0085231  0.0098904  -0.862 0.389443    
## as.factor(slide)5806484004 -0.0047447  0.0098904  -0.480 0.631735    
## as.factor(slide)5806484008 -0.0721901  0.0098904  -7.299 2.15e-12 ***
## as.factor(slide)5806484010 -0.0116631  0.0122314  -0.954 0.341010    
## as.factor(slide)5806484023 -0.0302780  0.0135695  -2.231 0.026325 *  
## as.factor(slide)5806484024  0.0282773  0.0093522   3.024 0.002692 ** 
## as.factor(slide)5806484056  0.0219614  0.0098904   2.220 0.027059 *  
## as.factor(slide)5806484057  0.0376597  0.0098904   3.808 0.000167 ***
## as.factor(slide)5806636054 -0.0340390  0.0214553  -1.587 0.113574    
## as.factor(slide)5815129004 -0.0308536  0.0091486  -3.373 0.000833 ***
## as.factor(slide)5815129009  0.0049498  0.0089754   0.551 0.581674    
## as.factor(slide)5815129011  0.0157928  0.0091486   1.726 0.085229 .  
## as.factor(slide)5815129015  0.0038162  0.0093522   0.408 0.683494    
## as.factor(slide)5815129018  0.0129406  0.0089754   1.442 0.150304    
## as.factor(slide)5815129027  0.0207926  0.0093522   2.223 0.026867 *  
## as.factor(slide)5815129028  0.0409617  0.0089754   4.564 7.08e-06 ***
## as.factor(slide)5815188011 -0.0019923  0.0098904  -0.201 0.840476    
## as.factor(slide)5815188020  0.0025035  0.0113531   0.221 0.825607    
## as.factor(slide)5815188021 -0.0062564  0.0098904  -0.633 0.527448    
## as.factor(slide)5815188022  0.0207620  0.0102576   2.024 0.043762 *  
## as.factor(slide)5815188023  0.0096351  0.0113531   0.849 0.396672    
## as.factor(slide)6229009001  0.1066514  0.0113531   9.394  < 2e-16 ***
## as.factor(slide)6229009004 -0.0004897  0.0098904  -0.050 0.960540    
## as.factor(slide)6229009040  0.0293303  0.0095951   3.057 0.002418 ** 
## as.factor(slide)6229009047  0.0320210  0.0122314   2.618 0.009250 ** 
## as.factor(slide)6229009049  0.0351427  0.0102576   3.426 0.000689 ***
## as.factor(slide)6229009050  0.0419299  0.0093522   4.483 1.01e-05 ***
## as.factor(slide)6229009056  0.0348482  0.0113531   3.069 0.002320 ** 
## as.factor(slide)6229009069  0.0545434  0.0098904   5.515 7.02e-08 ***
## as.factor(slide)6229009079  0.0366329  0.0102576   3.571 0.000408 ***
## as.factor(slide)6229009080  0.0355049  0.0107277   3.310 0.001036 ** 
## as.factor(slide)6229009083  0.0269746  0.0113531   2.376 0.018068 *  
## as.factor(slide)6229009084 -0.0146660  0.0135695  -1.081 0.280567    
## as.factor(slide)6229009100 -0.0462394  0.0113531  -4.073 5.81e-05 ***
## as.factor(slide)6229009101 -0.0818767  0.0159117  -5.146 4.56e-07 ***
## as.factor(slide)6229009106  0.0415944  0.0214553   1.939 0.053388 .  
## as.factor(slide)6229009107 -0.0657174  0.0159117  -4.130 4.59e-05 ***
## as.factor(slide)6229009112 -0.0731705  0.0107277  -6.821 4.28e-11 ***
## as.factor(slide)6229009147 -0.0267478  0.0214553  -1.247 0.213393    
## as.factor(slide)6229009151 -0.0442838  0.0122314  -3.620 0.000340 ***
## as.factor(slide)6229009153 -0.0289658  0.0214553  -1.350 0.177916    
## as.factor(slide)6229009162 -0.0330482  0.0095951  -3.444 0.000646 ***
## as.factor(slide)6229009166 -0.0395912  0.0159117  -2.488 0.013328 *  
## as.factor(slide)7810920047  0.1510512  0.0159117   9.493  < 2e-16 ***
## as.factor(slide)7810920048  0.0884394  0.0122314   7.231 3.32e-12 ***
## as.factor(slide)7810920075  0.1237393  0.0113531  10.899  < 2e-16 ***
## as.factor(slide)7810920088  0.0811932  0.0135695   5.983 5.64e-09 ***
## as.factor(slide)7810920089  0.0690426  0.0122314   5.645 3.55e-08 ***
## as.factor(slide)7810920091  0.0664004  0.0113531   5.849 1.18e-08 ***
## as.factor(slide)7810920102  0.0642807  0.0214553   2.996 0.002940 ** 
## as.factor(slide)7810920123  0.0823802  0.0113531   7.256 2.82e-12 ***
## as.factor(slide)7810920128  0.0567296  0.0214553   2.644 0.008579 ** 
## as.factor(slide)7810920166  0.0823127  0.0214553   3.836 0.000149 ***
## as.factor(slide)7810920178  0.0765063  0.0214553   3.566 0.000416 ***
## as.factor(slide)7927554017  0.0878568  0.0159117   5.522 6.78e-08 ***
## as.factor(slide)7927554041  0.0716784  0.0214553   3.341 0.000930 ***
## as.factor(slide)7927554078  0.1446794  0.0159117   9.093  < 2e-16 ***
## as.factor(slide)7927554080  0.1279431  0.0159117   8.041 1.58e-14 ***
## as.factor(slide)7927554092  0.1140251  0.0214553   5.315 1.96e-07 ***
## as.factor(slide)7927554093  0.1409568  0.0113531  12.416  < 2e-16 ***
## as.factor(slide)7927554109  0.1153304  0.0113531  10.159  < 2e-16 ***
## as.factor(slide)7927554120  0.1272110  0.0135695   9.375  < 2e-16 ***
## as.factor(slide)7927554124  0.1081595  0.0098904  10.936  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02035 on 333 degrees of freedom
## Multiple R-squared:  0.862,  Adjusted R-squared:  0.8335 
## F-statistic: 30.16 on 69 and 333 DF,  p-value: < 2.2e-16
summary(lm(PC3 ~ as.factor(slide), data = eigenvec_sd02_fetal_pheno))
## 
## Call:
## lm(formula = PC3 ~ as.factor(slide), data = eigenvec_sd02_fetal_pheno)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.34651 -0.09329  0.00000  0.05083  0.60359 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)
## (Intercept)                -0.06900    0.09212  -0.749    0.461
## as.factor(slide)5815188023  0.07481    0.11893   0.629    0.535
## as.factor(slide)5815188024  0.06817    0.11548   0.590    0.560
## as.factor(slide)5815188028  0.10548    0.11282   0.935    0.359
## as.factor(slide)6229009083 -0.11778    0.20599  -0.572    0.573
## as.factor(slide)6229009100 -0.08895    0.20599  -0.432    0.670
## as.factor(slide)6229009145  0.08426    0.13028   0.647    0.524
## as.factor(slide)6229009146  0.05815    0.15956   0.364    0.719
## as.factor(slide)6229009147  0.08390    0.20599   0.407    0.687
## as.factor(slide)7927554092  0.31446    0.20599   1.527    0.139
## 
## Residual standard error: 0.1842 on 25 degrees of freedom
## Multiple R-squared:  0.1514, Adjusted R-squared:  -0.1541 
## F-statistic: 0.4955 on 9 and 25 DF,  p-value: 0.8636
summary(lm(PC3 ~ as.factor(slide), data = eigenvec_jaffe_sd02_pheno))
## 
## Call:
## lm(formula = PC3 ~ as.factor(slide), data = eigenvec_jaffe_sd02_pheno)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.076794 -0.020122 -0.001515  0.016002  0.110748 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.0015023  0.0094348   0.159 0.873558    
## as.factor(slide)5771710015 -0.0183682  0.0149177  -1.231 0.218855    
## as.factor(slide)5771710017 -0.0011119  0.0133428  -0.083 0.933625    
## as.factor(slide)5771710022 -0.0215706  0.0133428  -1.617 0.106658    
## as.factor(slide)5771710023 -0.0231526  0.0139941  -1.654 0.098733 .  
## as.factor(slide)5771710036 -0.0246861  0.0139941  -1.764 0.078405 .  
## as.factor(slide)5771710037 -0.0313433  0.0144119  -2.175 0.030164 *  
## as.factor(slide)5771710038 -0.0212001  0.0144119  -1.471 0.141988    
## as.factor(slide)5806484002 -0.0431559  0.0188696  -2.287 0.022657 *  
## as.factor(slide)5806484004 -0.0181136  0.0139941  -1.294 0.196200    
## as.factor(slide)5806484008  0.0915242  0.0144119   6.351 5.26e-10 ***
## as.factor(slide)5806484010  0.0099247  0.0133428   0.744 0.457373    
## as.factor(slide)5806484023  0.0161199  0.0139941   1.152 0.249970    
## as.factor(slide)5806484024 -0.0004183  0.0139941  -0.030 0.976169    
## as.factor(slide)5806484056 -0.0240263  0.0149177  -1.611 0.107973    
## as.factor(slide)5806484057  0.0175715  0.0149177   1.178 0.239464    
## as.factor(slide)5806636054 -0.0007795  0.0136427  -0.057 0.954464    
## as.factor(slide)5806636077 -0.0274382  0.0163415  -1.679 0.093839 .  
## as.factor(slide)5815129004  0.0334782  0.0133428   2.509 0.012456 *  
## as.factor(slide)5815129009  0.0094631  0.0133428   0.709 0.478552    
## as.factor(slide)5815129011  0.0018414  0.0136427   0.135 0.892696    
## as.factor(slide)5815129015 -0.0104732  0.0133428  -0.785 0.432905    
## as.factor(slide)5815129018 -0.0198449  0.0133428  -1.487 0.137634    
## as.factor(slide)5815129027 -0.0065734  0.0136427  -0.482 0.630166    
## as.factor(slide)5815129028  0.0069788  0.0133428   0.523 0.601204    
## as.factor(slide)5815188010  0.0133147  0.0173969   0.765 0.444467    
## as.factor(slide)5815188011 -0.0234857  0.0139941  -1.678 0.093992 .  
## as.factor(slide)5815188020 -0.0126118  0.0136427  -0.924 0.355757    
## as.factor(slide)5815188021 -0.0017641  0.0144119  -0.122 0.902634    
## as.factor(slide)5815188022 -0.0002928  0.0155439  -0.019 0.984981    
## as.factor(slide)5815188023 -0.0166619  0.0133428  -1.249 0.212405    
## as.factor(slide)5815188024 -0.0208674  0.0155439  -1.342 0.180119    
## as.factor(slide)5815188028 -0.0108551  0.0144119  -0.753 0.451720    
## as.factor(slide)6229009001  0.0799988  0.0155439   5.147 3.97e-07 ***
## as.factor(slide)6229009004  0.0551002  0.0149177   3.694 0.000248 ***
## as.factor(slide)6229009040 -0.0003564  0.0139941  -0.025 0.979690    
## as.factor(slide)6229009047  0.0001961  0.0188696   0.010 0.991715    
## as.factor(slide)6229009049 -0.0004593  0.0155439  -0.030 0.976440    
## as.factor(slide)6229009050 -0.0119353  0.0136427  -0.875 0.382122    
## as.factor(slide)6229009056 -0.0099792  0.0173969  -0.574 0.566514    
## as.factor(slide)6229009069  0.0413650  0.0149177   2.773 0.005788 ** 
## as.factor(slide)6229009079 -0.0011548  0.0155439  -0.074 0.940810    
## as.factor(slide)6229009080 -0.0170259  0.0163415  -1.042 0.298029    
## as.factor(slide)6229009083 -0.0032263  0.0163415  -0.197 0.843579    
## as.factor(slide)6229009084  0.0218462  0.0210968   1.036 0.300984    
## as.factor(slide)6229009100  0.0274872  0.0149177   1.843 0.066049 .  
## as.factor(slide)6229009101  0.0653511  0.0249621   2.618 0.009143 ** 
## as.factor(slide)6229009106  0.1098497  0.0340176   3.229 0.001332 ** 
## as.factor(slide)6229009107  0.0395715  0.0210968   1.876 0.061344 .  
## as.factor(slide)6229009112  0.0351445  0.0163415   2.151 0.032039 *  
## as.factor(slide)6229009145  0.0497682  0.0188696   2.637 0.008642 ** 
## as.factor(slide)6229009146  0.0288833  0.0210968   1.369 0.171658    
## as.factor(slide)6229009147  0.0528690  0.0210968   2.506 0.012563 *  
## as.factor(slide)6229009151  0.0630915  0.0188696   3.344 0.000896 ***
## as.factor(slide)6229009153  0.0346271  0.0340176   1.018 0.309266    
## as.factor(slide)6229009162  0.0662782  0.0144119   4.599 5.53e-06 ***
## as.factor(slide)6229009166  0.1114727  0.0249621   4.466 1.01e-05 ***
## as.factor(slide)7810920047  0.0173749  0.0210968   0.824 0.410615    
## as.factor(slide)7810920048 -0.0285358  0.0163415  -1.746 0.081458 .  
## as.factor(slide)7810920075 -0.0256199  0.0173969  -1.473 0.141541    
## as.factor(slide)7810920088 -0.0301141  0.0188696  -1.596 0.111213    
## as.factor(slide)7810920089 -0.0298889  0.0188696  -1.584 0.113904    
## as.factor(slide)7810920091 -0.0403263  0.0163415  -2.468 0.013970 *  
## as.factor(slide)7810920102 -0.0406244  0.0340176  -1.194 0.233024    
## as.factor(slide)7810920123 -0.0442703  0.0173969  -2.545 0.011270 *  
## as.factor(slide)7810920128 -0.0608998  0.0155439  -3.918 0.000103 ***
## as.factor(slide)7810920166 -0.0623629  0.0210968  -2.956 0.003280 ** 
## as.factor(slide)7810920178 -0.0302890  0.0340176  -0.890 0.373732    
## as.factor(slide)7927554017 -0.0208255  0.0249621  -0.834 0.404565    
## as.factor(slide)7927554041 -0.0234184  0.0340176  -0.688 0.491544    
## as.factor(slide)7927554078 -0.0614372  0.0249621  -2.461 0.014222 *  
## as.factor(slide)7927554080 -0.0433592  0.0249621  -1.737 0.083073 .  
## as.factor(slide)7927554092 -0.0550576  0.0249621  -2.206 0.027915 *  
## as.factor(slide)7927554093 -0.0352741  0.0173969  -2.028 0.043190 *  
## as.factor(slide)7927554109 -0.0319275  0.0173969  -1.835 0.067132 .  
## as.factor(slide)7927554120 -0.0318497  0.0188696  -1.688 0.092127 .  
## as.factor(slide)7927554124 -0.0367302  0.0149177  -2.462 0.014184 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03268 on 449 degrees of freedom
## Multiple R-squared:  0.5204, Adjusted R-squared:  0.4392 
## F-statistic:  6.41 on 76 and 449 DF,  p-value: < 2.2e-16

1.5 Unsupervised cell clusters (ReFACTor in GLINT): age18

Settings for ReFACTor

  • include as covariates: age, sex, race, plate
  • needed to use model.matrix() to account for batch variables correctly

1.5.1 Compare against UMAP

refactor_k8_age18 <- fread(refactor_k8_age18_dir)
colnames(refactor_k8_age18)[1] <- "IID"

eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf <- join(eigenvec_sd02_age18_pheno_umap_ctp_jaffe, refactor_k8_age18, by = "IID", type = "inner")

eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf.tmp <- eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf[,c("IID", "UMAP1", "UMAP2", "rc1", "rc2", "rc3", "rc4", "rc5", "rc6", "rc7", "rc8")]

eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf.long <- melt(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf.tmp, id.vars = c("IID", "UMAP1", "UMAP2"), measure.vars = c("rc1", "rc2", "rc3", "rc4", "rc5", "rc6", "rc7", "rc8"), variable.name = "celltype", value.name = "CTP")

ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf.long, aes(x = UMAP1, y = UMAP2, alpha = 0.8)) + geom_point(aes(colour = CTP)) + facet_wrap(~ celltype) + scale_color_viridis(discrete = FALSE, option = "D")

rc1.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc1)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc2.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc2)) + scale_color_viridis(discrete = FALSE, option = "D") + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
rc3.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc3)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc4.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc4)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc5.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc5)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc6.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc6)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc7.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc7)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc8.umap <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc8)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")

ggarrange(rc1.umap, rc2.umap, rc3.umap, rc4.umap, rc5.umap, rc6.umap, rc7.umap, rc8.umap, nrow = 3, ncol = 3)

1.5.2 Control clusters: check correlation from clusters based on all vs controls only

  • correlation looks pretty good, though rc4, rc6, rc8 don’t do so well
refactor_k8_age18ctrl <- fread(refactor_k8_age18ctrl_dir)
colnames(refactor_k8_age18ctrl)[1] <- "IID"
refactor_k8_age18ctrl.tmp <- refactor_k8_age18ctrl
colnames(refactor_k8_age18ctrl.tmp) <- paste(colnames(refactor_k8_age18ctrl.tmp), "_ctrl", sep = "")

# Check correlation
datatable(data.frame(cor(refactor_k8_age18[,2:ncol(refactor_k8_age18)], refactor_k8_age18ctrl.tmp[,2:ncol(refactor_k8_age18ctrl.tmp)])) %>% mutate_if(is.numeric, ~round(., 2)))
eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf <- join(eigenvec_sd02_age18_pheno_umap_ctp_jaffe, refactor_k8_age18ctrl, by = "IID", type = "inner")

1.5.3 Compare against covariates: clusters_all

  • These should have been regressed out by ReFACTor
  • Exclude slide here to avoid +++ output - the plate should give a superficial idea
  • Takeaway: there remain some significant effects of covariates (ie. age, sex, race, plate) on the ReFACTor components
summary(lm(rc1 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc1 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -50.196 -12.934  -1.427   9.980  75.203 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)   
## (Intercept)      -3.74859    5.16533  -0.726  0.46844   
## groupSchizo      -5.71956    2.17281  -2.632  0.00881 **
## age               0.20699    0.06826   3.032  0.00259 **
## sexM              1.47732    2.09572   0.705  0.48127   
## raceCAUC         -2.22015    1.95919  -1.133  0.25782   
## plateLieber_244  -1.26248    3.91966  -0.322  0.74756   
## plateLieber_289  -3.74736    3.96198  -0.946  0.34481   
## plateLieber_30    4.69502    5.56413   0.844  0.39929   
## plateLieber_315 -12.99816    4.30241  -3.021  0.00268 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 19.17 on 394 degrees of freedom
## Multiple R-squared:  0.08608,    Adjusted R-squared:  0.06753 
## F-statistic: 4.639 on 8 and 394 DF,  p-value: 1.965e-05
summary(lm(rc2 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc2 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.6805  -2.8364  -1.0912   0.9004  23.4417 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -2.87368    1.75476  -1.638    0.102    
## groupSchizo      0.23613    0.73814   0.320    0.749    
## age              0.01259    0.02319   0.543    0.587    
## sexM             0.14543    0.71195   0.204    0.838    
## raceCAUC         0.08739    0.66557   0.131    0.896    
## plateLieber_244  1.35448    1.33158   1.017    0.310    
## plateLieber_289  7.03617    1.34596   5.228 2.79e-07 ***
## plateLieber_30  -1.64481    1.89024  -0.870    0.385    
## plateLieber_315 -2.39548    1.46161  -1.639    0.102    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.513 on 394 degrees of freedom
## Multiple R-squared:  0.2156, Adjusted R-squared:  0.1997 
## F-statistic: 13.54 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc3 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc3 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.4890 -1.9929 -0.2243  1.2562 26.0247 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      1.12607    0.88544   1.272 0.204208    
## groupSchizo      1.04925    0.37246   2.817 0.005090 ** 
## age             -0.06812    0.01170  -5.822 1.21e-08 ***
## sexM            -0.39733    0.35925  -1.106 0.269398    
## raceCAUC        -0.31879    0.33584  -0.949 0.343088    
## plateLieber_244  2.38348    0.67191   3.547 0.000436 ***
## plateLieber_289  1.77061    0.67916   2.607 0.009479 ** 
## plateLieber_30   1.66103    0.95380   1.741 0.082379 .  
## plateLieber_315  2.62693    0.73752   3.562 0.000413 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.286 on 394 degrees of freedom
## Multiple R-squared:  0.1542, Adjusted R-squared:  0.137 
## F-statistic: 8.978 on 8 and 394 DF,  p-value: 2.463e-11
summary(lm(rc4 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc4 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1055 -1.2898 -0.1654  1.1022  8.8620 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -3.622879   0.563880  -6.425 3.81e-10 ***
## groupSchizo      1.380377   0.237198   5.820 1.22e-08 ***
## age              0.023766   0.007451   3.189 0.001539 ** 
## sexM             0.530209   0.228781   2.318 0.020986 *  
## raceCAUC         0.352271   0.213878   1.647 0.100342    
## plateLieber_244  0.896808   0.427895   2.096 0.036732 *  
## plateLieber_289  1.546706   0.432514   3.576 0.000392 ***
## plateLieber_30   0.866805   0.607416   1.427 0.154361    
## plateLieber_315  3.173083   0.469678   6.756 5.12e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.093 on 394 degrees of freedom
## Multiple R-squared:  0.2839, Adjusted R-squared:  0.2694 
## F-statistic: 19.53 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc5 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc5 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.0509 -0.9352 -0.0727  0.7095 10.9364 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.817120   0.436784   1.871 0.062119 .  
## groupSchizo     -0.459487   0.183734  -2.501 0.012796 *  
## age              0.004150   0.005772   0.719 0.472570    
## sexM            -0.338866   0.177215  -1.912 0.056579 .  
## raceCAUC        -0.029108   0.165671  -0.176 0.860620    
## plateLieber_244 -1.512885   0.331449  -4.564  6.7e-06 ***
## plateLieber_289 -0.348133   0.335028  -1.039 0.299388    
## plateLieber_30  -0.402215   0.470507  -0.855 0.393152    
## plateLieber_315  1.387553   0.363815   3.814 0.000159 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.621 on 394 degrees of freedom
## Multiple R-squared:  0.3079, Adjusted R-squared:  0.2938 
## F-statistic: 21.91 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc6 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc6 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.3811 -0.6282 -0.0359  0.5441  9.6260 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.777353   0.385530   2.016 0.044444 *  
## groupSchizo     -0.024106   0.162174  -0.149 0.881913    
## age             -0.029326   0.005095  -5.756 1.73e-08 ***
## sexM             0.339484   0.156420   2.170 0.030578 *  
## raceCAUC         0.525841   0.146230   3.596 0.000364 ***
## plateLieber_244 -0.001722   0.292555  -0.006 0.995307    
## plateLieber_289  0.625127   0.295714   2.114 0.035146 *  
## plateLieber_30   1.052701   0.415295   2.535 0.011636 *  
## plateLieber_315 -0.727861   0.321123  -2.267 0.023955 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.431 on 394 degrees of freedom
## Multiple R-squared:  0.2172, Adjusted R-squared:  0.2013 
## F-statistic: 13.67 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc7 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc7 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.1076 -0.4327 -0.0346  0.3352 10.9504 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.906101   0.257691   3.516 0.000489 ***
## groupSchizo      0.455125   0.108398   4.199 3.32e-05 ***
## age              0.002918   0.003405   0.857 0.392012    
## sexM             0.083733   0.104552   0.801 0.423687    
## raceCAUC        -0.101293   0.097741  -1.036 0.300681    
## plateLieber_244 -0.821094   0.195546  -4.199 3.32e-05 ***
## plateLieber_289 -1.424635   0.197657  -7.208 2.93e-12 ***
## plateLieber_30  -1.064588   0.277586  -3.835 0.000146 ***
## plateLieber_315 -2.967459   0.214641 -13.825  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9564 on 394 degrees of freedom
## Multiple R-squared:  0.431,  Adjusted R-squared:  0.4194 
## F-statistic:  37.3 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc8 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc8 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.9294 -0.3620  0.0924  0.4551  8.0985 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.87607    0.24289   3.607 0.000350 ***
## groupSchizo     -0.18630    0.10217  -1.823 0.068994 .  
## age             -0.02775    0.00321  -8.647  < 2e-16 ***
## sexM             0.22659    0.09855   2.299 0.022007 *  
## raceCAUC        -0.08381    0.09213  -0.910 0.363521    
## plateLieber_244  0.07730    0.18431   0.419 0.675142    
## plateLieber_289  0.94899    0.18630   5.094 5.45e-07 ***
## plateLieber_30  -0.12183    0.26164  -0.466 0.641740    
## plateLieber_315  0.79356    0.20231   3.922 0.000103 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9015 on 394 degrees of freedom
## Multiple R-squared:  0.2963, Adjusted R-squared:  0.282 
## F-statistic: 20.74 on 8 and 394 DF,  p-value: < 2.2e-16

1.5.4 Compare against covariates: clusters_ctrl

  • These should have been regressed out by ReFACTor
  • Exclude slide here to avoid +++ output - the plate should give a superficial idea
  • Takeaway: there remain some significant effects of covariates (ie. age, sex, race, plate) on the ReFACTor components
  • Effects are slightly different (eg. sig assoc between rc8_ctrl and group but not rc8 calculated from all individuals)
summary(lm(rc1 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc1 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -52.505 -13.132  -1.012  10.475  72.888 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)   
## (Intercept)      -4.58577    5.14998  -0.890  0.37377   
## groupSchizo      -5.82787    2.16635  -2.690  0.00745 **
## age               0.21808    0.06805   3.204  0.00146 **
## sexM              1.70534    2.08948   0.816  0.41491   
## raceCAUC         -2.08817    1.95337  -1.069  0.28572   
## plateLieber_244  -1.30844    3.90801  -0.335  0.73795   
## plateLieber_289  -2.99201    3.95020  -0.757  0.44924   
## plateLieber_30    4.66227    5.54759   0.840  0.40119   
## plateLieber_315 -13.22719    4.28962  -3.084  0.00219 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 19.11 on 394 degrees of freedom
## Multiple R-squared:  0.09027,    Adjusted R-squared:  0.0718 
## F-statistic: 4.887 on 8 and 394 DF,  p-value: 9.085e-06
summary(lm(rc2 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc2 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.3000  -3.0061  -0.9706   0.9739  21.9817 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -2.337812   1.768439  -1.322   0.1869    
## groupSchizo      0.504245   0.743898   0.678   0.4983    
## age             -0.001956   0.023369  -0.084   0.9333    
## sexM             0.151450   0.717503   0.211   0.8329    
## raceCAUC         0.074550   0.670762   0.111   0.9116    
## plateLieber_244  1.344387   1.341963   1.002   0.3171    
## plateLieber_289  7.216097   1.356450   5.320 1.75e-07 ***
## plateLieber_30  -1.822313   1.904975  -0.957   0.3394    
## plateLieber_315 -2.441416   1.473003  -1.657   0.0982 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.563 on 394 degrees of freedom
## Multiple R-squared:   0.22,  Adjusted R-squared:  0.2042 
## F-statistic: 13.89 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc3 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc3 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.837 -1.591 -0.317  1.164 32.219 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -0.26426    0.80207  -0.329 0.741970    
## groupSchizo      1.47522    0.33739   4.372 1.57e-05 ***
## age             -0.04086    0.01060  -3.856 0.000135 ***
## sexM            -0.17047    0.32542  -0.524 0.600682    
## raceCAUC        -0.18102    0.30422  -0.595 0.552164    
## plateLieber_244  1.76320    0.60864   2.897 0.003979 ** 
## plateLieber_289  1.40724    0.61521   2.287 0.022702 *  
## plateLieber_30   0.95659    0.86400   1.107 0.268895    
## plateLieber_315  3.32407    0.66808   4.976 9.74e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.977 on 394 degrees of freedom
## Multiple R-squared:  0.1562, Adjusted R-squared:  0.139 
## F-statistic: 9.115 on 8 and 394 DF,  p-value: 1.613e-11
summary(lm(rc4 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc4 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.5734 -1.0505 -0.0138  0.7280 18.6318 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -2.110301   0.656045  -3.217 0.001404 ** 
## groupSchizo      0.451427   0.275967   1.636 0.102680    
## age              0.009533   0.008669   1.100 0.272160    
## sexM             0.618564   0.266175   2.324 0.020639 *  
## raceCAUC         0.687164   0.248835   2.762 0.006022 ** 
## plateLieber_244 -0.141407   0.497833  -0.284 0.776525    
## plateLieber_289  1.446438   0.503208   2.874 0.004267 ** 
## plateLieber_30   1.431998   0.706696   2.026 0.043404 *  
## plateLieber_315  1.840211   0.546446   3.368 0.000833 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.435 on 394 degrees of freedom
## Multiple R-squared:  0.1653, Adjusted R-squared:  0.1484 
## F-statistic: 9.755 on 8 and 394 DF,  p-value: 2.219e-12
summary(lm(rc5 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc5 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.7165 -0.9833  0.0471  0.7964 16.8847 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.91337    0.44422   2.056  0.04043 *  
## groupSchizo     -0.63766    0.18686  -3.412  0.00071 ***
## age              0.01635    0.00587   2.785  0.00561 ** 
## sexM            -0.40719    0.18023  -2.259  0.02441 *  
## raceCAUC        -0.27224    0.16849  -1.616  0.10695    
## plateLieber_244 -1.57844    0.33709  -4.683  3.9e-06 ***
## plateLieber_289 -1.02090    0.34073  -2.996  0.00291 ** 
## plateLieber_30  -1.27914    0.47851  -2.673  0.00783 ** 
## plateLieber_315  0.36993    0.37000   1.000  0.31802    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.649 on 394 degrees of freedom
## Multiple R-squared:  0.2454, Adjusted R-squared:   0.23 
## F-statistic: 16.01 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc6 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc6 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1321 -0.9396 -0.0846  0.7006  8.5491 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      2.152023   0.417593   5.153 4.05e-07 ***
## groupSchizo     -0.747526   0.175661  -4.256 2.61e-05 ***
## age             -0.034995   0.005518  -6.342 6.24e-10 ***
## sexM            -0.242724   0.169429  -1.433  0.15276    
## raceCAUC         0.108214   0.158391   0.683  0.49488    
## plateLieber_244  0.114497   0.316886   0.361  0.71806    
## plateLieber_289 -0.002388   0.320307  -0.007  0.99406    
## plateLieber_30   0.582538   0.449833   1.295  0.19608    
## plateLieber_315 -0.928223   0.347829  -2.669  0.00793 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.55 on 394 degrees of freedom
## Multiple R-squared:  0.2133, Adjusted R-squared:  0.1973 
## F-statistic: 13.35 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc7 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc7 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.4728 -0.4083  0.0593  0.4395 10.7724 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.391486   0.288899   1.355   0.1762    
## groupSchizo      0.281259   0.121526   2.314   0.0212 *  
## age              0.003127   0.003818   0.819   0.4132    
## sexM             0.257547   0.117214   2.197   0.0286 *  
## raceCAUC        -0.061622   0.109578  -0.562   0.5742    
## plateLieber_244 -0.215077   0.219228  -0.981   0.3272    
## plateLieber_289 -0.982224   0.221595  -4.433 1.21e-05 ***
## plateLieber_30  -0.774703   0.311204  -2.489   0.0132 *  
## plateLieber_315 -2.634870   0.240636 -10.950  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.072 on 394 degrees of freedom
## Multiple R-squared:  0.3952, Adjusted R-squared:  0.3829 
## F-statistic: 32.18 on 8 and 394 DF,  p-value: < 2.2e-16
summary(lm(rc8 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc8 ~ group + age + sex + race + plate, data = eigenvec_sd02_age18ctrl_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7388 -0.4152  0.0534  0.5095  5.7071 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -0.619663   0.240975  -2.571   0.0105 *  
## groupSchizo     -0.410174   0.101367  -4.046 6.26e-05 ***
## age             -0.007010   0.003184  -2.201   0.0283 *  
## sexM             0.102755   0.097770   1.051   0.2939    
## raceCAUC        -0.163560   0.091401  -1.789   0.0743 .  
## plateLieber_244  0.911337   0.182862   4.984 9.36e-07 ***
## plateLieber_289  1.529894   0.184836   8.277 1.98e-15 ***
## plateLieber_30   0.583664   0.259580   2.248   0.0251 *  
## plateLieber_315  2.007873   0.200718  10.003  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8944 on 394 degrees of freedom
## Multiple R-squared:  0.3048, Adjusted R-squared:  0.2907 
## F-statistic: 21.59 on 8 and 394 DF,  p-value: < 2.2e-16

1.5.5 Correlate with Jaffe processed cell-types: clusters_all

  • do see strong correlation (r > 0.90) for rc1 and NeuN+/-
  • correlation between rc2 and comp_es (0.61) / comp_npc (r = 0.68)
    • interestingly though, not with age

1.5.6 Correlate with Jaffe processed cell-types: clusters_ctrl

  • do see strong correlation (r > 0.90) for rc1 and NeuN+/-
  • correlation between rc2 and comp_es (0.61) / comp_npc (r = 0.62)
    • interestingly though, not with age
  • rc3: stronger correlation with comp_neun_neg
  • rc4: stronger correlation with comp_neun_neg
  • rc5: weaker correlation with comp_neun_neg
  • rc6: stronger correlation with comp_da_neuron
  • rc7: weaker correlation with comp_es than before
  • rc8: weaker correlation with comp_da_neuron

1.5.6.1 Follow up rc2

  • Rationale: looks like there are 2 distinct clusters for rc2
  • Wonder if this is age-related (there are some clumps here too)
  • Plot rc2 vs npcs and overlay various variables
  • Takeaway: looks batchy!
rc2_npc.group <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = rc2, y = comp_npc, colour = group)) + geom_point(alpha = 0.8) + theme(legend.position = "bottom")
rc2_npc.sex <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = rc2, y = comp_npc, colour = sex)) + geom_point(alpha = 0.8) + theme(legend.position = "bottom")
rc2_npc.age <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = rc2, y = comp_npc, colour = age)) + geom_point(alpha = 0.8) + scale_colour_viridis() + theme(legend.position = "bottom")
rc2_npc.race <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = rc2, y = comp_npc, colour = race)) + geom_point(alpha = 0.8) + theme(legend.position = "bottom")
rc2_npc.plate <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = rc2, y = comp_npc, colour = plate)) + geom_point(alpha = 0.8) + scale_colour_viridis(discrete = TRUE) + theme(legend.position = "bottom")

ggarrange(rc2_npc.group, rc2_npc.sex, rc2_npc.age, rc2_npc.race, rc2_npc.plate, nrow = 3, ncol = 2)

Check Slide variable too

  • on its own as the legend is big and messay
rc2_npc.slide <- ggplot(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, aes(x = rc2, y = comp_npc, colour = slide)) + geom_point(alpha = 0.8, aes(colour = as.factor(slide))) + scale_colour_viridis(discrete = TRUE) + theme(legend.position = "bottom")

rc2_npc.slide

1.5.7 Check probe annotations: clusters_all

  • ReFACTor provides list of most informative probes, though doesn’t assign to celltypes
  • Check annotations, simply based on 450K manifest
  • Does look “neural”, but not canonical marker genes to my naive eye

1.5.8 Check probe annotations: clusters_ctrl

  • looks very similar to above from a cursory look

1.5.9 Trace back top probes to ReFACTor components: clusters_all

Extract n=500 probes from OSCA to get a smaller matrix

  • I think this number is more appropriate as n=500 is the default number of probes to include in the ReFACTor analysis
  • Plot heatmap
  • Output interactive table to identify probes relating most to each component
#refactor_k8_age18 <- fread(refactor_k8_age18_dir)
refactor_k8_age18_n500.ma <- fread(refactor_k8_age18_n500.ma_dir)

identical(refactor_k8_age18$IID, colnames(refactor_k8_age18_n500.ma)[2:ncol(refactor_k8_age18_n500.ma)])
## [1] TRUE
# TRUE

tmp.rc <- as.matrix(refactor_k8_age18[,c("rc1", "rc2", "rc3", "rc4", "rc5", "rc6", "rc7", "rc8")])
tmp.beta <- as.matrix(refactor_k8_age18_n500.ma[,2:ncol(refactor_k8_age18_n500.ma)])

refactor_k8_age18_n500.cor <- cor(t(tmp.beta), tmp.rc)
rownames(refactor_k8_age18_n500.cor) <- refactor_k8_age18_n500.ma$ID

heatmap(refactor_k8_age18_n500.cor, scale="column", col = terrain.colors(120))

refactor_k8_age18_n500.cor.anno <- join(data.frame(probe = rownames(refactor_k8_age18_n500.cor), refactor_k8_age18_n500.cor), refactor_k8_age18_probe_anno.df, by = "probe", type = "inner")

datatable(refactor_k8_age18_n500.cor.anno %>% mutate_if(is.numeric, ~round(., 2)))

1.5.10 Trace back top probes to ReFACTor components: clusters_ctrl

Extract n=500 probes from OSCA to get a smaller matrix

  • I think this number is more appropriate as n=500 is the default number of probes to include in the ReFACTor analysis
  • Plot heatmap
  • Output interactive table to identify probes relating most to each component
#refactor_k8_age18 <- fread(refactor_k8_age18_dir)
refactor_k8_age18ctrl_n500.ma <- fread(refactor_k8_age18ctrl_n500.ma_dir)

identical(refactor_k8_age18ctrl$IID, colnames(refactor_k8_age18ctrl_n500.ma)[2:ncol(refactor_k8_age18ctrl_n500.ma)])
## [1] TRUE
# TRUE

tmp.rc <- as.matrix(refactor_k8_age18ctrl[,c("rc1", "rc2", "rc3", "rc4", "rc5", "rc6", "rc7", "rc8")])
tmp.beta <- as.matrix(refactor_k8_age18ctrl_n500.ma[,2:ncol(refactor_k8_age18ctrl_n500.ma)])

refactor_k8_age18ctrl_n500.cor <- cor(t(tmp.beta), tmp.rc)
rownames(refactor_k8_age18ctrl_n500.cor) <- refactor_k8_age18ctrl_n500.ma$ID

heatmap(refactor_k8_age18ctrl_n500.cor, scale="column", col = terrain.colors(120))

refactor_k8_age18ctrl_n500.cor.anno <- join(data.frame(probe = rownames(refactor_k8_age18ctrl_n500.cor), refactor_k8_age18ctrl_n500.cor), refactor_k8_age18ctrl_probe_anno.df, by = "probe", type = "inner")

datatable(refactor_k8_age18ctrl_n500.cor.anno %>% mutate_if(is.numeric, ~round(., 2)))

1.6 Unsupervised cell clusters (ReFACTor in GLINT): fetal

Settings for ReFACTor

  • include as covariates: age, sex, race, plate
  • needed to use model.matrix() to account for batch variables correctly

1.6.1 Compare against UMAP

refactor_k8_fetal <- fread(refactor_k8_fetal_dir)
colnames(refactor_k8_fetal)[1] <- "IID"

eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf <- join(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe, refactor_k8_fetal, by = "IID", type = "inner")

eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf.tmp <- eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf[,c("IID", "UMAP1", "UMAP2", "rc1", "rc2", "rc3", "rc4", "rc5", "rc6", "rc7", "rc8")]

eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf.long <- melt(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf.tmp, id.vars = c("IID", "UMAP1", "UMAP2"), measure.vars = c("rc1", "rc2", "rc3", "rc4", "rc5", "rc6", "rc7", "rc8"), variable.name = "celltype", value.name = "CTP")

ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf.long, aes(x = UMAP1, y = UMAP2, alpha = 0.8)) + geom_point(aes(colour = CTP)) + facet_wrap(~ celltype) + scale_color_viridis(discrete = FALSE, option = "D")

rc1.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc1)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc2.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc2)) + scale_color_viridis(discrete = FALSE, option = "D") + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
rc3.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc3)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc4.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc4)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc5.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc5)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc6.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc6)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc7.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc7)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")
rc8.umap <- ggplot(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf, aes(x = UMAP1, y = UMAP2)) + geom_point(alpha = 0.8, aes(colour = rc8)) + scale_color_viridis(discrete = FALSE, option = "D") + theme(legend.position = "bottom")

ggarrange(rc1.umap, rc2.umap, rc3.umap, rc4.umap, rc5.umap, rc6.umap, rc7.umap, rc8.umap, nrow = 3, ncol = 3)

1.6.2 Compare against covariates

  • These should have been regressed out by ReFACTor
  • Exclude slide here to avoid +++ output - the plate should give a superficial idea
  • Don’t include group here as all controls in fetal group
summary(lm(rc1 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc1 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -15.677  -5.804  -2.817   1.703 117.368 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)        1.714     60.139   0.029    0.977
## age              -10.547    143.085  -0.074    0.942
## sexM              -7.152      8.271  -0.865    0.395
## raceCAUC          -6.596     14.964  -0.441    0.663
## plateLieber_244   -6.519     12.948  -0.503    0.619
## plateLieber_289   -6.023     10.051  -0.599    0.554
## plateLieber_315   -1.845     24.657  -0.075    0.941
## 
## Residual standard error: 23.39 on 28 degrees of freedom
## Multiple R-squared:  0.04766,    Adjusted R-squared:  -0.1564 
## F-statistic: 0.2335 on 6 and 28 DF,  p-value: 0.962
summary(lm(rc2 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc2 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.106 -3.001 -1.155  1.483 18.661 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)      -0.2061    12.6291  -0.016    0.987
## age              -2.1863    30.0475  -0.073    0.943
## sexM             -0.4850     1.7370  -0.279    0.782
## raceCAUC         -2.4158     3.1424  -0.769    0.448
## plateLieber_244  -2.8180     2.7191  -1.036    0.309
## plateLieber_289  -0.5870     2.1107  -0.278    0.783
## plateLieber_315   6.3660     5.1779   1.229    0.229
## 
## Residual standard error: 4.911 on 28 degrees of freedom
## Multiple R-squared:  0.111,  Adjusted R-squared:  -0.07948 
## F-statistic: 0.5828 on 6 and 28 DF,  p-value: 0.7409
summary(lm(rc3 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc3 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.9885 -0.9276  0.1730  0.7611  2.4303 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -24.6726     3.1111  -7.930 1.23e-08 ***
## age             -57.5353     7.4020  -7.773 1.82e-08 ***
## sexM             -0.3343     0.4279  -0.781 0.441266    
## raceCAUC          0.8514     0.7741   1.100 0.280740    
## plateLieber_244   2.6396     0.6698   3.941 0.000493 ***
## plateLieber_289   0.1540     0.5200   0.296 0.769208    
## plateLieber_315   1.4494     1.2755   1.136 0.265452    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.21 on 28 degrees of freedom
## Multiple R-squared:  0.7382, Adjusted R-squared:  0.682 
## F-statistic: 13.16 on 6 and 28 DF,  p-value: 4.883e-07
summary(lm(rc4 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc4 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7533 -0.6797  0.0000  0.6994  2.3721 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       3.7693     2.8118   1.341  0.19085    
## age              12.0370     6.6899   1.799  0.08276 .  
## sexM              0.4514     0.3867   1.167  0.25296    
## raceCAUC         -0.4589     0.6996  -0.656  0.51727    
## plateLieber_244   1.9091     0.6054   3.154  0.00383 ** 
## plateLieber_289   3.7647     0.4699   8.011 1.01e-08 ***
## plateLieber_315  -0.8468     1.1528  -0.735  0.46871    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.093 on 28 degrees of freedom
## Multiple R-squared:  0.7227, Adjusted R-squared:  0.6633 
## F-statistic: 12.16 on 6 and 28 DF,  p-value: 1.05e-06
summary(lm(rc5 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc5 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.4616 -0.4362  0.1402  0.4582  3.3423 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)   
## (Intercept)      -8.2644     3.0651  -2.696  0.01173 * 
## age             -20.5002     7.2925  -2.811  0.00891 **
## sexM             -0.4560     0.4216  -1.082  0.28866   
## raceCAUC          0.2949     0.7627   0.387  0.70192   
## plateLieber_244  -1.3699     0.6599  -2.076  0.04720 * 
## plateLieber_289  -0.4027     0.5123  -0.786  0.43837   
## plateLieber_315   0.8608     1.2567   0.685  0.49898   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.192 on 28 degrees of freedom
## Multiple R-squared:  0.3342, Adjusted R-squared:  0.1916 
## F-statistic: 2.343 on 6 and 28 DF,  p-value: 0.0585
summary(lm(rc6 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc6 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5380 -0.7423  0.0000  0.5810  1.6944 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)   
## (Intercept)     -3.73744    2.52711  -1.479  0.15032   
## age             -9.35096    6.01257  -1.555  0.13112   
## sexM             0.14143    0.34757   0.407  0.68716   
## raceCAUC        -0.03202    0.62880  -0.051  0.95974   
## plateLieber_244  0.72617    0.54410   1.335  0.19275   
## plateLieber_289 -1.20513    0.42235  -2.853  0.00805 **
## plateLieber_315 -2.03938    1.03611  -1.968  0.05901 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9827 on 28 degrees of freedom
## Multiple R-squared:  0.3784, Adjusted R-squared:  0.2452 
## F-statistic: 2.841 on 6 and 28 DF,  p-value: 0.02744
summary(lm(rc7 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc7 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2178 -0.1937 -0.0293  0.2421  3.2523 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)   
## (Intercept)       0.3269     2.2239   0.147   0.8842   
## age               1.2865     5.2911   0.243   0.8097   
## sexM             -0.2369     0.3059  -0.774   0.4452   
## raceCAUC          0.2260     0.5534   0.408   0.6861   
## plateLieber_244   1.2503     0.4788   2.611   0.0143 * 
## plateLieber_289   0.3276     0.3717   0.881   0.3857   
## plateLieber_315   2.7928     0.9118   3.063   0.0048 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8648 on 28 degrees of freedom
## Multiple R-squared:  0.3528, Adjusted R-squared:  0.2141 
## F-statistic: 2.544 on 6 and 28 DF,  p-value: 0.04299
summary(lm(rc8 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf))
## 
## Call:
## lm(formula = rc8 ~ age + sex + race + plate, data = eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.18498 -0.30955 -0.00028  0.27176  1.88630 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)   
## (Intercept)      0.39160    2.12916   0.184  0.85540   
## age              1.00925    5.06577   0.199  0.84352   
## sexM            -0.25843    0.29284  -0.882  0.38503   
## raceCAUC         0.16994    0.52978   0.321  0.75077   
## plateLieber_244  0.48351    0.45842   1.055  0.30056   
## plateLieber_289 -0.02254    0.35584  -0.063  0.94995   
## plateLieber_315  3.14950    0.87295   3.608  0.00119 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8279 on 28 degrees of freedom
## Multiple R-squared:  0.3409, Adjusted R-squared:  0.1996 
## F-statistic: 2.413 on 6 and 28 DF,  p-value: 0.05251

1.6.3 Correlate with Jaffe processed cell-types

  • good to see that there look to be trends between age and cellular composition as inferred by Jaffe et al.
  • rc1 and increased comp_da_neuron / decreased comp_npc
  • rc2 and increased NeuN -ive / decreased NeuN +ive
  • rc3 and increased comp_es (+ decreased age which is a nice sanity check) and decreased NeuN +ive
  • rc4 and decreased Neun -ive / increased NeuN +ive
  • rc5 and increased comp_es
  • rc6 and increased comp_da_neuron
  • note that there is an outlier that may be skewing results

1.6.3.1 Identify and check rc1/comp_da_neuron outlier

  • find this is the same person!
eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf[which(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf$rc1 == max(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf$rc1)),]
##                 FID              IID       PC1       PC2       PC3      PC4
## 1: Sample19_Control Sample19_Control -0.674668 -0.580362 -0.340695 0.156399
##          PC5       PC6        PC7        PC8        PC9      PC10     PC11
## 1: 0.0212083 0.0337158 -0.0202028 -0.0485313 -0.0969421 0.0292195 0.111271
##          PC12       PC13      PC14       PC15       PC16       PC17       PC18
## 1: -0.0550832 -0.0284861 0.0184859 0.00581602 -0.0199274 0.00751685 0.00755818
##         PC19        PC20   group       age sex race      plate      slide
## 1: 0.0292292 -0.00518256 Control -0.421917   F   AA Lieber_104 5815188023
##    sentrix_row sentrix_col      UMAP1     UMAP2 comp_da_neuron   comp_es
## 1:           3           2 -0.4793697 0.7660486      0.1608904 0.1065557
##    comp_neun_neg comp_neun_pos comp_npc     rc1       rc2       rc3        rc4
## 1:     0.3388347     0.2658577        0 123.532 -2.596077 0.1559752 -0.9562762
##           rc5        rc6         rc7         rc8
## 1: -0.1439078 -0.2354442 -0.02970016 -0.04059768
eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf[which(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf$comp_da_neuron == max(eigenvec_sd02_fetal_pheno_umap_ctp_jaffe_rf$comp_da_neuron)),]
##                 FID              IID       PC1       PC2       PC3      PC4
## 1: Sample19_Control Sample19_Control -0.674668 -0.580362 -0.340695 0.156399
##          PC5       PC6        PC7        PC8        PC9      PC10     PC11
## 1: 0.0212083 0.0337158 -0.0202028 -0.0485313 -0.0969421 0.0292195 0.111271
##          PC12       PC13      PC14       PC15       PC16       PC17       PC18
## 1: -0.0550832 -0.0284861 0.0184859 0.00581602 -0.0199274 0.00751685 0.00755818
##         PC19        PC20   group       age sex race      plate      slide
## 1: 0.0292292 -0.00518256 Control -0.421917   F   AA Lieber_104 5815188023
##    sentrix_row sentrix_col      UMAP1     UMAP2 comp_da_neuron   comp_es
## 1:           3           2 -0.4793697 0.7660486      0.1608904 0.1065557
##    comp_neun_neg comp_neun_pos comp_npc     rc1       rc2       rc3        rc4
## 1:     0.3388347     0.2658577        0 123.532 -2.596077 0.1559752 -0.9562762
##           rc5        rc6         rc7         rc8
## 1: -0.1439078 -0.2354442 -0.02970016 -0.04059768

1.6.3.2 Re-run correlation removing this outlier

  • note that there excluding just this individual induces a correlation between rc
  • NO LONGER big asssociation: rc1 and increased comp_da_neuron / decreased comp_npc
  • find there is still a nice correlation for some rc eg.
  • rc2 and increased NeuN -ive / decreased NeuN +ive
  • rc3 and increased comp_es (+ decreased age which is a nice sanity check) and decreased NeuN +ive
  • rc4 and decreased Neun -ive / increased NeuN +ive
  • rc5 and increased comp_es

1.6.4 Check probe annotations

  • ReFACTor provides list of most informative probes, though doesn’t assign to celltypes
  • Check annotations, simply based on 450K manifest
  • Don’t seem glaringly “neural” to my naive eye, seem to be more poorly annotated genes (eg. pseudogenes, miRNA, LINCs, etc.)

1.6.5 Trace back top probes to ReFACTor components

Extract n=500 probes from OSCA to get a smaller matrix

  • I think this number is more appropriate as n=500 is the default number of probes to include in the ReFACTor analysis
  • Plot heatmap
  • Output interactive table to identify probes relating most to each component
#refactor_k8_fetal <- fread(refactor_k8_fetal_dir)
refactor_k8_fetal_n500.ma <- fread(refactor_k8_fetal_n500.ma_dir)

identical(refactor_k8_fetal$IID, colnames(refactor_k8_fetal_n500.ma)[2:ncol(refactor_k8_fetal_n500.ma)])
## [1] TRUE
# TRUE

tmp.rc <- as.matrix(refactor_k8_fetal[,c("rc1", "rc2", "rc3", "rc4", "rc5", "rc6", "rc7", "rc8")])
tmp.beta <- as.matrix(refactor_k8_fetal_n500.ma[,2:ncol(refactor_k8_fetal_n500.ma)])

refactor_k8_fetal_n500.cor <- cor(t(tmp.beta), tmp.rc)
rownames(refactor_k8_fetal_n500.cor) <- refactor_k8_fetal_n500.ma$ID

heatmap(refactor_k8_fetal_n500.cor, scale="column", col = terrain.colors(120))

refactor_k8_fetal_n500.cor.anno <- join(data.frame(probe = rownames(refactor_k8_fetal_n500.cor), refactor_k8_fetal_n500.cor), refactor_k8_fetal_probe_anno.df, by = "probe", type = "inner")

datatable(refactor_k8_fetal_n500.cor.anno %>% mutate_if(is.numeric, ~round(., 2)))

1.7 Supervised (Houseman): age18

hm_na2 <- fread(hm_na2_dir)
hm_na5 <- fread(hm_na5_dir)

colnames(hm_na2)[1] <- "IID"
colnames(hm_na5)[1] <- "IID"

1.7.1 Join datasets

eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf_hmna2 <- join(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, hm_na2, by = "IID", type = "inner")

eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf_hmna5 <- join(eigenvec_sd02_age18_pheno_umap_ctp_jaffe_rf, hm_na5, by = "IID", type = "inner")

1.7.2 Correlations between supervised and unsupervised

100 nearest probes

500 nearest probes